From: Vincent Pit Date: Sun, 10 Jan 2010 00:18:58 +0000 (+0100) Subject: Add a caveat about dereferencing slices X-Git-Tag: v0.04~2 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=95c40a32d06dcfdd1815cd7c5f4b362f4f9cec85;p=perl%2Fmodules%2Fautovivification.git Add a caveat about dereferencing slices --- diff --git a/lib/autovivification.pm b/lib/autovivification.pm index 1bab02f..ab0fc22 100644 --- a/lib/autovivification.pm +++ b/lib/autovivification.pm @@ -151,6 +151,12 @@ sub import { (); } +=head1 CAVEATS + +The pragma doesn't apply when one dereferences the returned value of an array or hash slice, as in C<< @array[$id]->{member} >> or C<< @hash{$key}->{member} >>. +This syntax is valid Perl, yet it's discouraged as the slice is here useless since the dereferencing enforces scalar context. +If warnings are turned on, Perl will complain about one-element slices. + =head1 DEPENDENCIES L 5.8.