#... LINE: while ( my $line = ) { chomp $line; # skip all lines which don't contain "EUR/USD" at the beginning next LINE if $line !~ m{^\s*EUR/USD}; # split $line at pattern '\s*,\s*' into at most 3 pieces # and ignore the first piece # for details, see: perldoc -f split my ( $value, $rest ) = ( split( m{\s*,\s*}, $line, 3 )[1,2]; # extract the timestamp from the third piece my $time = ( split m{ }, $rest, 2 )[0]; print "$name : $value : $time\n"; }