[Omaha.pm] pushing arrays onto arrays?
Jay Hannah
jhannah at omnihotels.com
Fri Mar 16 10:29:22 PDT 2007
Nope. :)
What you expected would happen if you did "push @a, \@b".
j
________________________________
From: Sean Baker
Sent: Thursday, March 15, 2007 8:51 AM
To: Programmers
Subject: pushing arrays onto arrays?
Wow.
I always thought that if you "push @a, @b", the @b would end up as some
type of reference in the @a array. I guess not.
#!/usr/bin/perl
use strict;
# Push @b stuff onto @a separately.
#
my @a = qw(1 2 3);
my @b = qw(4 5 6);
foreach (@b) {
push @a, $_;
}
print join " ", @a;
print "\n";
# push @b onto @a.
#
my @a = qw(1 2 3);
my @b = qw(4 5 6);
push @a, @b;
print join " ", @a;
exit;
More information about the Omaha-pm
mailing list