package Parse::Books; use strict; use warnings; sub parse { my $FH = shift; my @books; my $counter = -1; while (<$FH>) { chomp; next if /<.*>/; if (/^Title: *(.*)/) { $counter++; } if (/(.*): *(.*)/) { warn "Duplicate field $1 at # $counter line $.\n" if exists $books[$counter]{$1}; $books[$counter]{$1} = $2; } } return \@books; }
In reply to Re: Perl Module to parse text file
by choroba
in thread Perl Module to parse text file
by Gary Yang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |