my $struct = {
hashRef => { fruit => 'apple', veggie => 'corn' },
arrayRef => [ qw(1 2 3 4 5) ],
};
####
#!/usr/bin/env perl5
use strict;
use warnings;
my $struct = {
hashRef => { fruit => 'apple', veggie => 'corn' },
arrayRef => [ qw(1 2 3 4 5) ],
};
# These two are the same; perl adds the implicit '->' to the first and
# turns it into the second internally
print $struct->{hashRef}{fruit}, "\n";
print $struct->{hashRef}->{fruit}, "\n";
# Now we'll deref the $struct->{hashRef} hash reference via ${} instead
# of ->
print ${$struct->{hashRef}}{fruit}, "\n";
# And for the coup de grace, we'll deref $struct via ${} instead of ->
# too.
print ${${$struct}{hashRef}}{fruit}, "\n";
##
##
% ./tst.pl
apple
apple
apple
apple