in reply to Re: Precedence of qw
in thread Precedence of qw

Sorry about that; it wasn't my intent.

I noticed something else that I posted. This:
#!/usr/bin/perl -w use strict; my $scalar = qw(A B C); print $scalar, "\n";
Gives:
Use of implicit split to @_ is deprecated at ./test27.pl line 4.
3

And perldiag has:
Use of implicit split to @_ is deprecated
(D deprecated) It makes a lot of work for the compiler when you clobber a subroutine's argument list, so it's better if you assign the results of a split() explicitly to an array (or list).

I'm not sure how these are related...

Replies are listed 'Best First'.
Re^3: Precedence of qw
by ikegami (Patriarch) on Apr 04, 2006 at 17:07 UTC

    Your version of perl probably implements
    qw(A B C)
    as
    split(' ', q(A B C))
    (although I suspect it performs said split at compile-time).

    Given the above, consider the following passage from split's documentation:

    In scalar context, returns the number of fields found and splits into the @_ array. Use of split in scalar context is deprecated, however, because it clobbers your subroutine arguments.

    If you want the count, use my $scalar = () = qw(A B C);.

    By the way, I said "your version of perl" because perl 5.6.1 gives

    Useless use of a constant in void context at 541192.pl line 4. Useless use of a constant in void context at 541192.pl line 4. C

      The split is performed at runtime for perl prior to 5.6..

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Re^3: Precedence of qw
by duff (Parson) on Apr 04, 2006 at 17:02 UTC

    What version of perl are you using? Mine doesn't say that at all.

      duff, version 5.005_03 built for sun4-solaris. We have other versions on other machines; I'll try those out.

        Perl prior to 5.6 implemented qw() as a split() to be executed at runtime.

        ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Re^3: Precedence of qw
by codeacrobat (Chaplain) on Apr 04, 2006 at 21:37 UTC
    $ perl -w use strict; my $scalar = qw(A B C); Useless use of a constant in void context at - line 3. Useless use of a constant in void context at - line 3. print $scalar, "\n"; C
    $ perl -v This is perl, v5.8.7 built for cygwin-thread-multi-64int (with 1 registered patch, see perl -V for more detail)
    By the way, this has nothing to do with qw.
    $ perl -w my $scalar = (1, 2, 3); Useless use of a constant in void context at - line 1.