Re: confused about reference



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

.



Relevant Pages

  • Re: Best place to learn perl?
    ... > # do perl stuff here ... reference to an array, and we're dereferencing it. ... Each element of THAT array points to another hash reference. ...
    (comp.lang.perl.misc)
  • Re: Complex (for me) reference deconstruction
    ... $t->contains an array reference ... is a hash key within the hash referenced by $r ...
    (comp.lang.perl.misc)
  • confused about reference
    ... I was just testing some reference and while trying out below I am trying to understand below ... But I am trying to really understand whether this is trying to say since value of 'yahoo' is array put @ at the front? ... what is the difference between %vs %Are we here talking about first being hash reference which first item is array reference vs second one is hash reference's first item? ... use strict; ...
    (perl.beginners)
  • Re: VB-101: Passing Arrays ByVal vs ByRef
    ... changed if an array is passed by Val. ... ' new reference ... As each function creates a new array object, ... 'secondArray' and 'secondArrayCopy'. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Need help with textboxes
    ... The JavaScript 1.5 Reference already states: ... All forms and their children are stored in an array ... use dot notation or object literals. ... No. Bracket property accessors allow their argument to be any string value. ...
    (comp.lang.javascript)