sub Msg { my $line = shift; my ($pf,$fixFields) = split(/received:|Sent:/, $line); my %fixMsg = split(/[,=]/, $fixFields); @fixMsg{('_time_', '_mi_', '_fixsession_')} = (split(/\|/, $pf))[2,3,5]; return \%fixMsg; } open( my $file, '<', "abc.txt" ) or die "Unable to open data file - $!\n"; while(<$file>){ my $msg = pfUtils::Msg($_); my %skip_keys = map {$_ => undef} qw( _mi_ _fixsession_ _time_ ); foreach my $key ( sort keys %$msg ) { next if exists $skip_keys{$key}; my $value = $msg->{$key}; next unless defined $value and length $value; my $code = 'where did this come from?'; printf "\n\t%20s (%3d) = %s ", $code,$key,$value; } } close $file;