Chas. Owens wrote:
On Apr 19, 2008, at 12:39, Richard Lee wrote:
what is the difference?? I thought doing [ ] and \ would do the
samething
snip
They do similar, but different, things. The \ operator takes a
reference to a variable and [] operator creates an anonymous array.
You can build [] from \ by using a temporary array that goes out of
scope.
my $linked = [EMAIL PROTECTED];
my $independent = do { #this is functionally the same as my
$independent = [EMAIL PROTECTED];
my @temp = @array;
[EMAIL PROTECTED];
}
Changes to @$linked will change @array, but changes to @$independent
will not.
--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
I think I understand now.. thanks.
Also, part of my the other problem was that i was shifting only one item
in sub.. which confused me even more.
[EMAIL PROTECTED] tmp]# cat !$
cat ./sdf.pl
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
my %something = (
something_a => 1,
something_b => 2,
something_c => 3,
);
my %something2 = (
something2_a => 1,
something2_b => 2,
);
sub process_it {
my $some = shift;
print Dumper($some);
}
my @total = ( \%something, \%something2 ) ; # second one
process_it(@total);
[EMAIL PROTECTED] tmp]# ./!$
././sdf.pl
$VAR1 = {
'something_c' => 3,
'something_b' => 2,
'something_a' => 1
};
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/