X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperldiag.pod;h=780aefc25075776a9aee5d86848f165f7ae484e6;hb=c885792efecf3f527b3b5099727cc16b03eee1dc;hp=49d30fcab05f009baaf29832aed80b911c56fec6;hpb=a034a98d8bfd0fd904012bd5227ce209aaaa0b26;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 49d30fc..780aefc 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -1815,7 +1815,7 @@ shifting or popping (for array variables). See L. =item Scalar value @%s[%s] better written as $%s[%s] -(W) You've used an array slice (indicated by @) to select a single value of +(W) You've used an array slice (indicated by @) to select a single element of an array. Generally it's better to ask for a scalar value (indicated by $). The difference is that C<$foo[&bar]> always behaves like a scalar, both when assigning to it and when evaluating its argument, while C<@foo[&bar]> behaves @@ -1827,6 +1827,20 @@ element as a list, you need to look into how references work, because Perl will not magically convert between scalars and lists for you. See L. +=item Scalar value @%s{%s} better written as $%s{%s} + +(W) You've used a slice (indicated by @) to select a single element of +a hash. Generally it's better to ask for a scalar value (indicated by $). +The difference is that C<$foo{&bar}> always behaves like a scalar, both when +assigning to it and when evaluating its argument, while C<@foo{&bar}> behaves +like a list when you assign to it, and provides a list context to its +subscript, which can do weird things if you're expecting only one subscript. + +On the other hand, if you were actually hoping to treat the hash +element as a list, you need to look into how references work, because +Perl will not magically convert between scalars and lists for you. See +L. + =item Script is not setuid/setgid in suidperl (F) Oddly, the suidperl program was invoked on a script with its setuid