Re: confused about reference

2008-10-30 Thread Richard Lee

Richard Lee wrote:


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?
@{$yahoo->{yahoo}}  has @ on it because it's value of yahoo is 
reference. Is this right?


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 ?

This one, I cannot figure it out



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)}



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




confused about reference

2008-10-30 Thread Richard Lee


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)}

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/