in reply to qw() problem

qw stands for "quote words". So qw(name1, name2, name3) is equivalent to ('name1,', 'name2,', 'name3')


$\=~s;s*.*;q^|D9JYJ^^qq^\//\\\///^;ex;print

Replies are listed 'Best First'.
Re^2: qw() problem
by gargle (Chaplain) on Oct 10, 2005 at 12:00 UTC

    HI,

    careful with those comma's:

    perl -e '@a = qw(a, b, c);map { print "$_\n"; } @a'

    gives:

    a, b, c

    While:

    perl -e '@a = qw(a b c);map { print "$_\n"; } @a'

    gives:

    a b c

    With qw you can skip the comma...

    UPDATE: sorry for the spelling mistake. It's commas! I've been reading slashdot too much lately.

    --
    if ( 1 ) { $postman->ring() for (1..2); }

      Not can skip but (in most cases) should skip.

      OTOH: You should have replied to the OP. I know of that fact, that's why I said that it's equivalent to

      ('name1,', 'name2,', 'name3')
      and not
      ('name1', 'name2', 'name3')

      Update: Just a side note ;-) Careful with those apostrophes! Generally there is no such thing as a plural apostrophe in any language I know of english and german. So it should be "commas" not "comma's" ;-)

      Update 2: Thanks to Perl Mouse I've learnd that the dutch language has a plural apostrophe in some cases. That's the reason for the correction above...


      $\=~s;s*.*;q^|D9JYJ^^qq^\//\\\///^;ex;print
      A reply falls below the community's threshold of quality. You may see it by logging in.
      A reply falls below the community's threshold of quality. You may see it by logging in.