Richard Lee wrote:
Chas. Owens wrote:
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.
one more question,
why does below not work?
while ( my ($key,$value) = each( %{$oj_s} ) ) {
print "$key and $value\n";
}
assuming that
oj_s contains
$VAR1 = {
'abc' => '10.0.0.1_1035',
'cde' => '192.168.1.1_1037',
'fgh' => '192.168.100.1_10',
}
It works for me:
$ perl -le'
my $oj_s = {
abc => "10.0.0.1_1035",
cde => "192.168.1.1_1037",
fgh => "192.168.100.1_10",
};
while ( my ($key,$value) = each( %{$oj_s} ) ) {
print "$key and $value";
}
'
fgh and 192.168.100.1_10
cde and 192.168.1.1_1037
abc and 10.0.0.1_1035
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/