Click to See Complete Forum and Search --> : -perl- array referencing..


corrumpu
01-18-2001, 12:02 PM
How do array references really work..
correct me if i'm wrong. they are more or less a pointer to an array.. so if i pass in a reference to a sub.. use push(@$refernce,$somestuff) .. it should push onto the array i am making reference to?
correct?

::chris:: aka [perl-newbie]


reason i ask.. i'm using this.. and i have a post a few down from this one.. i ironed out other problems, but this seems to be a nagging question.

[This message has been edited by corrumpu (edited 18 January 2001).]

YaRness
01-18-2001, 01:52 PM
yes exactly. if you don't believe me ( http://www.linuxnewbie.org/ubb/biggrin.gif ), run this:

#!/usr/local/bin/perl -w
use strict;
my @array = (1,2,3);
my $ref = \@array;
push @$ref, "4";
print @array;



------------------
"Assembly of Japanese bicycle require great peace of mind."
Registered Linux User #188285 http://counter.li.org/