confused about reference
- From: rich.japh@xxxxxxxxx (Richard Lee)
- Date: Thu, 30 Oct 2008 23:08:40 -0400
I was just testing some reference and while trying out below I am trying to understand below
@{$yahoo->{yahoo}}........... I can see that this is pointing to 0,1,3 by running the code.
But I am trying to really understand whether this is trying to say since value of 'yahoo' is array put @ at the front?
or @ is there because it's array slice??
Can someone explain this?
Also, %{$base[0]}, trying to understand this.
According to the tutorial,
%base referenced is %{$base}
what is the difference between %{$base[0]} vs %{$base}[0] Are we here talking about first being hash reference which first item is array reference vs second one is hash reference's first item ?
thank you.
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
my $yahoo = { 'yahoo' => [ 0, 1, 3],
'msn' => [ 12, 32, 44]
};
print Dumper($yahoo);
print "\n\n\n\n\n------------------------------------------------------------\n";
print "${$yahoo}{yahoo}[0]\n"; # prints 0
print "$yahoo->{yahoo}[0]\n"; # prints 0
print "@{$yahoo->{yahoo}}\n"; # prints 0,1,3
print "%{$yahoo->{yahoo}}\n"; # print %{ARRAY(0x832e8c4)}
.
- Follow-Ups:
- Re: confused about reference
- From: Richard Lee
- Re: confused about reference
- Prev by Date: How to put a global variable in a package, accessible to users of that package?
- Next by Date: Re:confused about reference
- Previous by thread: How to put a global variable in a package, accessible to users of that package?
- Next by thread: Re: confused about reference
- Index(es):
Relevant Pages
|