my $text = "1 2 3 4 5 6"; my @tokens = split(/\s+/,$text,2); foreach (@tokens) { print "$_\n"; } #prints: 1 2 3 4 5 6