# $record stores references to hashes, # which are accumulated in @records # my ($record, @records); for my $line ( break_into_lines( $resp->content() ) ) { if ( $line =~ /CANDIDATE/ ) { # # Save previous record, if there is one # if ( defined $record ) { push( @records, $record ); } $records = {}; # assign a new anon. hash. } # In the hash referenced by $record, use the 'protein' key # to access an array into which the $protein is/are added. # while ( my ( $protein ) = ( $line =~ /$protein_re/g ) ) { push( @{ $record->{'protein'} }, $protein ); } if ( my ( $score ) = ( $line =~ /$score_re/g ) ) { push( @{ $record->{'score'} }, $score ); } }