my @foo; my $next_a = <DATA>; scalar(<DATA>); until (eof(DATA)) { my $a = $next_a; my @b; while (my $line = <DATA>) { last if $line =~ /^[*]{16}$/; push @b, $line; } my $found_next; my @c; while (my $line = <DATA>) { last if $found_next = ($line =~ /^-{16}$/); push @c, $line; } $next_a = pop(@c) if $found_next; push @foo, { a => $a, b => join("" => @b), c => join("" => @c), }; } use Data::Dumper; print Dumper \@foo; __END__ title 1 ---------------- a few random lines of more random text **************** some more random text title 2 ---------------- cow jumped over the moon **************** corn on the cob lobster thermidor
In reply to Re: breaking a text file into a data structure -- best way?
by repellent
in thread breaking a text file into a data structure -- best way?
by punkish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |