in reply to Re^5: warning: use of uninitialized value
in thread warning: use of uninitialized value

I think the Cookbook recommends an even easier and more reliable method for splitting on white space:

my @tokenarray = split ' ', $anystring;

Replies are listed 'Best First'.
Re^7: warning: use of uninitialized value
by hippo (Archbishop) on Jun 25, 2015 at 19:22 UTC

    You don't even need to go as far as the cookbook for that, it's right there in the documentation for split:

    As another special case, split emulates the default behavior of the command line tool awk when the PATTERN is either omitted or a literal string composed of a single space character (such as ' ' or "\x20" , but not e.g. / / ). In this case, any leading whitespace in EXPR is removed before splitting occurs, and the PATTERN is instead treated as if it were /\s+/ ; in particular, this means that any contiguous whitespace (not just a single space character) is used as a separator. However, this special treatment can be avoided by specifying the pattern / / instead of the string " " , thereby allowing only a single space character to be a separator. In earlier Perls this special case was restricted to the use of a plain " " as the pattern argument to split, in Perl 5.18.0 and later this special case is triggered by any expression which evaluates as the simple string " " .

      Right you are! And that special behavior from split ' ' is why early on I made that my standard ws splitting idiom except in unusual cases.