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; }