On Wed, May 30, 2001 at 03:38:35PM -0500, Nichole Bialczyk wrote:
> i'm trying to work my way throuh an existing script and it says
>
> @array = qw("stuff", "more stuff", "even more stuff");
>
> what does the qw do?
perldoc perlop:
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/);
In this case, qw is being misused. The code there is equivalent to:
$array[0] = '"stuff",' ;
$array[1] = '"more' ;
$array[2] = 'stuff",' ;
$array[3] = '"even' ;
$array[4] = 'more' ;
$array[5] = 'stuff"' ;
What was probably intended is the equivalent of:
$array[0] = "stuff" ;
$array[1] = "more stuff" ;
$array[2] = "even more stuff";
In which case the qw should just be dropped, the quoting is sufficient.
Michael
--
Administrator www.shoebox.net
Programmer, System Administrator www.gallanttech.com
--