use strict; use warnings; my $fileStr = <)) { my @lines = grep {/^\s*\d+\s+\S+\s+-?\d+\.\d+/} split "\n", $record; next if !@lines; my %recordData = map{/\d+\s+(\S+)\s+(\S+)/; ($1, $2)} @lines; my @solvents = grep {!/^F\d+/} keys %recordData; my @fractions = grep {/^F\d+/} keys %recordData; my ($zeroSolvent) = grep {0.0 == $recordData{$_}} @solvents; print "${zeroSolvent}_$_ => $recordData{$_}\n" for @fractions; }