On Friday 16 September 2005 12:08, Anthony Gardner wrote: > Can s.o. explain what is wrong with the following code > .... > > $r->pnotes('KEY' => push( @{ $ar }, $some_val ) ); > > because, when it comes to getting the value from > pnotes later with .... $r->pnotes(KEY), it returns the > number of elements in the array and not the array ref. > > I've had to write ...... > > my $ar = $r->pnotes('KEY') || []; > push( @{ $ar }, $debug_str ); > $r->pnotes( 'KEY' => $ar );
Quoteing perldoc -f push: push ARRAY,LIST Treats ARRAY as a stack, and pushes the values of LIST onto the end of ARRAY. The length of ARRAY increases by the length of LIST. Has the same effect as for $value (LIST) { $ARRAY[++$#ARRAY] = $value; } but is more efficient. Returns the new number of elements in the array. push returns the new number of elements. This is what you see. Torsten
pgpeceNylCbKr.pgp
Description: PGP signature