note
jwkrahn
<blockquote><i>
There are cases where it is equally easy to use a regexp in list context to split a string as it is to use the split function. Consider the following examples:
<c>
my @list = split /\s+/, $string;
my @list = $string =~ /(\S+)/g;
</c>
In the first example you're defining what to throw away. In the second, you're defining what to keep. But you're getting the same results. That is a case where it's equally easy to use either syntax.
</i></blockquote>
<p>
In your regexp example you don't need the parentheses, it will work the same without them.
</p>
<p>
If <b><c>$string</c></b> contains leading whitespace then you will <b>NOT</b> get the same results. To demonstrate examples that produce the same results:
<c>
my @list = split ' ', $string;
my @list = $string =~ /\S+/g;
</c>
591988
591988