SPUG: List
Jim Flanagan
jimfl at colltech.com
Wed Jul 11 11:35:26 CDT 2001
--Also Sprache Martin Korb <mkorb at versuslaw.com> On Wednesday, July 11,
2001 8:49 AM -0700:
> my $citeList = [];
>
> push @@$citeList, $with_something
That should produce a compile-time error.
A single @ should be fine. The notation '[]' creates a reference to an
empty array, so now $citeList is an array reference. To actually push
something onto the array that the reference points to, you have to fool
push into thinking you actually have an array,
push @{$citeList}, $with_something;
But Perl allows a shorthand in the absence of ambiguity, and you can say
push @$citeList, $with_something;
and you can get that entry by saying
$citeList->[0];
# or
${$citeList}[0];
Now, if you say
push @{@$citeList}, $with_something;
You get the same result as above, but you've made perl work a little
harder for it.
SEE ALSO
the perlref() manual page
--
Jim Flanagan Collective Technologies
jimfl at colltech.com http://www.colltech.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
More information about the spug-list
mailing list