in reply to Process Records Spread Across Multiple Lines
What you wrote is easy to read but, for me, the following is easier...
my @rec; while (<$fh>) { my $entry = parse_line($_); if (@rec and $entry->{key} ne $rec[0]->{key}) { process_rec(\@rec); @rec = (); } push @rec, $entry; } process_rec(\@rec); sub parse_line { my ($line) = @_; chomp($line); my %entry; # ... return \%entry; } sub process_rec { my ($rec) = @_; return if ! @$rec; # ... }
|
|---|