Return-Path: Delivered-To: apmail-perl-modperl-archive@www.apache.org Received: (qmail 11042 invoked from network); 16 Sep 2005 11:06:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 16 Sep 2005 11:06:26 -0000 Received: (qmail 20961 invoked by uid 500); 16 Sep 2005 11:06:18 -0000 Delivered-To: apmail-perl-modperl-archive@perl.apache.org Received: (qmail 20945 invoked by uid 500); 16 Sep 2005 11:06:17 -0000 Mailing-List: contact modperl-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list modperl@perl.apache.org Received: (qmail 20932 invoked by uid 99); 16 Sep 2005 11:06:17 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Sep 2005 04:06:17 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of torsten.foertsch@gmx.net designates 213.165.64.20 as permitted sender) Received: from [213.165.64.20] (HELO mail.gmx.net) (213.165.64.20) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 16 Sep 2005 04:06:27 -0700 Received: (qmail invoked by alias); 16 Sep 2005 11:06:14 -0000 Received: from p54AD1710.dip0.t-ipconnect.de (EHLO opi.home) [84.173.23.16] by mail.gmx.net (mp030) with SMTP; 16 Sep 2005 13:06:14 +0200 X-Authenticated: #1700068 Received: by opi.home (Postfix, from userid 1000) id EB6143DF58; Fri, 16 Sep 2005 12:33:18 +0200 (CEST) From: Torsten Foertsch To: modperl@perl.apache.org Subject: Re: Sth I don't understand about pnotes Date: Fri, 16 Sep 2005 12:33:12 +0200 User-Agent: KMail/1.7.1 References: <20050916100825.57764.qmail@web26008.mail.ukl.yahoo.com> In-Reply-To: <20050916100825.57764.qmail@web26008.mail.ukl.yahoo.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2839451.8Pa99HrCf7"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200509161233.18592.torsten.foertsch@gmx.net> X-Y-GMX-Trusted: 0 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --nextPart2839451.8Pa99HrCf7 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 --nextPart2839451.8Pa99HrCf7 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQBDKp9uwicyCTir8T4RAnKhAJ42Q6DAZQnebeiCwmz+ImLpHmSLRgCeIGVW dwfY+IaYDxpu/QYtlzNTAtw= =6VAC -----END PGP SIGNATURE----- --nextPart2839451.8Pa99HrCf7--