From: Roderick Schertler Date: Tue, 31 Dec 1996 16:50:19 +0000 (-0500) Subject: Re: perldiag.pod entry for "Scalar value @%s{%s} ..." X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c885792efecf3f527b3b5099727cc16b03eee1dc;p=p5sagit%2Fp5-mst-13.2.git Re: perldiag.pod entry for "Scalar value @%s{%s} ..." On Mon, 30 Dec 1996 21:28:30 -0500, Gurusamy Sarathy said: > On Mon, 30 Dec 1996 21:09:12 EST, Roderick Schertler wrote: >> >> +=item Scalar value @%s{%s} better written as $%s{%s} >> + >> +This is just like the previous entry, but for hashes instead of arrays. >> + > > Won't that look odd under -Mdiagnostics? Better to spell it out > again. Right you are. This diff goes on top of the one above. p5p-msgid: <2043.852051019@eeyore.ibcinc.com> --- 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