This would work, You'll get hash of arrays
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $HASH; my $Title; while ( <DATA> ) { chomp; next if ! $_; if ( /^\d+\.(.*)/sg ) { $Title = $1; $HASH->{$Title} = []; next; } if ( exists $HASH->{$Title} ) { push @{$HASH->{$Title}} , $_; } } print Dumper($HASH); __DATA__ 1.TITLE OF FIRST RECIPE abstract Recipe 1. Recipe 2. Recipe ... Procedure... 2.TITLE OF SECOND RECIPE ...
In reply to Re: Regexp and reading a file n-lines at time
by ahmad
in thread Regexp and reading a file n-lines at time
by epimenidecretese
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |