summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoderick Schertler <roderick@gate.net>1996-12-31 11:50:19 -0500
committerChip Salzenberg <chip@atlantic.net>1997-01-01 08:59:00 +1200
commitc885792efecf3f527b3b5099727cc16b03eee1dc (patch)
tree00936e0024876f90b41949aacc68b807975415a8
parenta034a98d8bfd0fd904012bd5227ce209aaaa0b26 (diff)
downloadperl-c885792efecf3f527b3b5099727cc16b03eee1dc.tar.gz
Re: perldiag.pod entry for "Scalar value @%s{%s} ..."
On Mon, 30 Dec 1996 21:28:30 -0500, Gurusamy Sarathy <gsar@engin.umich.edu> 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>
-rw-r--r--pod/perldiag.pod16
1 files changed, 15 insertions, 1 deletions
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 49d30fcab0..780aefc250 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -1815,7 +1815,7 @@ shifting or popping (for array variables). See L<perlform>.
=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<perlref>.
+=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<perlref>.
+
=item Script is not setuid/setgid in suidperl
(F) Oddly, the suidperl program was invoked on a script with its setuid