use strict; use warnings; while () { if ( (my $first,my $second) = /^(\S+)\s+(\S+)/ ) #ok, allow an extra spaces between tokens { print "$first $second\n"; } } #prints: hello one __DATA__ hello one two three kjsf kjsd kjd