in reply to String to tokens

An alternative is to use the @array = $str =~ /(pattern)/g idiom...
sub foo { my $str = shift; my @text = $str =~ /(\S+)/g; ... } # call as foo("This is a test");