> Robin <[EMAIL PROTECTED]> suggested: >> This will split up the string based on the pattern (in this >> case, a single space. You may want to change that to gain >> robustness, e.g. /[ \t]+/ will split on any number of spaces and tabs) > > I suggest /\s+/ instead. This splits on any whitespace, > and it'll also remove trailing whitespace like those > pesky trailing \n:
And further, use split(' ',$numbers), which is a special case that splits on all whitespace, ignoring initial whitespace. Just a bare "split" does that by default. Try this: perl -e '$_ = " 1 2 3 4 5 "; print "method 1: ", join(",",split /\s+/), "\n", "method 2: ", join(",",split), "\n";' - B