Tuesday, December 28, 2010

Use array references with the array operators in Perl

#Use array references with the array operators

my $ref = [ qw(Buster Mimi Ginger Ella) ];
sub get_dogs { [ qw(Nicki Addy) ] }
push @$ref, 'Addy';
print "Pets are @$ref\n";
my $dog = shift @{ get_dogs() };
print "Dog is $dog\n";

No comments: