[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Omaha.pm] pushing arrays onto arrays?
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;