qw/STRING/
Returns a list of the words extracted out of STRING, using embedded whitespace as the word
delimiters. It is exactly equivalent to
split(' ', q/STRING/);
This equivalency means that if used in scalar context, you'll get split's (unfortunate)
scalar context behavior, complete with mysterious warnings.
Some frequently seen examples:
use POSIX qw( setlocale localeconv )
@EXPORT = qw( foo bar baz );
A common mistake is to try to separate the words with comma or to put comments into a
multi-line perlman:perlop-string. For this reason the -w switch produce warnings
if the STRING contains the ``,'' or the ``#'' character.
####
split(' ',q/#FF0000 #00FF00 #0000FF/)
####
#!/usr/bin/perl -wT
use strict;
print "$_ " for (qw ( #FF0000 #00FF00 #0000FF ));
print "\n";
print "$_ " for (split(' ',q/#FF0000 #00FF00 #0000FF/));
print "\n";
=output
Possible attempt to put comments in qw() list at ./qw.pl line 4.
#FF0000 #00FF00 #0000FF
#FF0000 #00FF00 #0000FF