in reply to why qw() rather than ()

AFIC, qw() allows you to separate the entries with whitespace. That's pretty convenient. Look at this:
$ perl -e 'print join(", ",qw(1 3 6 2));' 1, 3, 6, 2
But trying that without the qw gives:
[jeroen@rulffk] perl -e 'print join(", ",(1 3 6 2));' Number found where operator expected at -e line 1, near "1 3" (Missing operator before 3?) syntax error at -e line 1, near "1 3" Number found where operator expected at -e line 1, near "3 6" (Missing operator before 6?) Number found where operator expected at -e line 1, near "6 2" (Missing operator before 2?) Execution of -e aborted due to compilation errors.
Hope this helps.

Jeroen
"We are not alone"(FZ)

Replies are listed 'Best First'.
Re: Re: why qw() rather than ()
by arhuman (Vicar) on Jan 22, 2001 at 18:30 UTC
    Ok ! thanks for the answer ! I've totally miss the separator problem !

    So, if I've understood

    use Digest::MD5  qw(md5 md5_hex md5_base64);

    is exactly the same as

    use Digest::MD5(md5,md5_hex,md5_base64);


      Well, if you add a space after MD5 ;-).

      But that's not the whole thing. From the manpage:

      =item 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/); 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 qw-string. For this reason the C<-w> switch produce warnings if the STRING contains the "," or the "#" character.
      So, there is a difference, although small.

      Jeroen
      "We are not alone"(FZ)

      No.

      Using strict would point out the error for you.