in reply to Re: Password Program
in thread Password Program

If this statement is run with warnings asserted, what will Perl say about the statement?

Unfortunately, nothing... the "Scalar value @wrongPasswords[4] better written as $wrongPasswords[4]" warning you're probably referring to doesn't seem to get triggered by the assignment.

$ perl -wMstrict my @foo; @foo[3] = "bar"; print @foo[3], "\n"; __END__ Scalar value @foo[3] better written as $foo[3] at - line 3. bar

Replies are listed 'Best First'.
Re^3: Password Program
by Laurent_R (Canon) on Mar 01, 2015 at 10:13 UTC
    Well, yes, it seems to be trigerred by the assignment:
    $ perl -wMstrict -e 'my @foo; @foo[3] = "bar";' Scalar value @foo[3] better written as $foo[3] at -e line 2.

    Je suis Charlie.

      Aha! perl5200delta:

      The warning "Scalar value @hash{foo} better written as $hash{foo}" now produces far fewer false positives. In particular, @hash{+function_returning_a_list} and @hash{ qw "foo bar baz" } no longer warn. The same applies to array slices. [perl #28380, #114024]

      The commit is 429a25554a6. The argument for this change was that something like this is useful:

      use warnings; use strict; my @foo; $foo[0] = "abcd"=~/b(.)/; # scalar context @foo[1] = "abcd"=~/b(.)/; # list context print "{$_}\n" for @foo; __END__ {1} {c}