[prev in list] [next in list] [prev in thread] [next in thread]
List: apache-modperl
Subject: Re: [offtopic] perl newbie frustrated
From: tomas () tuxteam ! de
Date: 2006-07-18 15:02:27
Message-ID: 20060718150227.GA8058 () www ! trapp ! net
[Download RAW message or body]
On Sat, Jul 15, 2006 at 02:12:34AM -0400, Jonathan Vanasco wrote:
>
> On Jul 13, 2006, at 7:41 PM, Philip M. Gollucci wrote:
[...]
> I thought read once that within an array declaration, [] is a real
> array and not a reference-- or did i dream that up and have been
> dealing with anonymous arrays all along?
Well, both :-)
>
> ie:
>
> my @real= ( 1 , [11,12,13] , 2 ,[21,22,23] );
> my $ref= [1,2,3];
>
> i could have sworn i read that when @real is compiled, the array-in-
> an-array is real array and not a ref
The construct [1,2,3] allocates a real array somewhere in Perl's belly
and returns a ref to it, much like the construct
char *str="abracadabra";
allocates a character array in C, but puts a pointer to it in the
variable *str.
So [1, 2, [3, 4, 5], 6]
just makes an array of 4 entries (of which the third, that's the one
with index 2, is a reference to a freshly allocated array of three
entries) and yields a raference to this whole thing.
So well, real arrays are involved somewhere, and you (or your code) get
a handle to those.
> i'm hopped up on too much codeine right now (bronchitis), so i'm
> thinking less clearly than normal. forgive what's probably a stupid
> question.
But you got it right, somehow ;-)
I hope your bronchitis gets better
-- tomás
["signature.asc" (application/pgp-signature)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic