my @output = `./some_executable.out -f $some_param`; my %nhash; foreach my $output (@output) { chomp($output); my ( $tm, $val ) = split( " ", $output ); print "BEFORE: $tm\n"; # this regex is not robust because it can't capture « $tm =~ s/L//; print "AFTER: $tm\n"; $nhash{$tm} = $val; } #### # sometime this: $tm = 'fooL'; # other time this: $tm = 'foo«';