in reply to Hash Ref Error
I'll test and explain if nobody else does shortly.
Update: There's nothing technically wrong with your code, and it should work (as the Monks who tested it below can show). However, it isn't the most idiomatic Perl out there. Right off the bat, although perl allows whitespace nearly anywhere, it's clearer if you keep your delimiters together: ${ $my_data_ref }{ names }
What this does:
${ $my_data_ref } { names }is it dereferences $my_data_ref hash reference, and converts (actually it forces) the value(s) of its names key into a scalar value. It is equivalent to the more idiomatic:
my $scalar = $my_data_ref->{names}Both do the same thing, but one is a bit more understandable at-a-glance, so long as the left-hand side (or within another line or two) makes it clear what type (scalar or list) you're pulling out.
-stevieb
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hash Ref Error
by Maresia (Beadle) on Sep 15, 2015 at 21:43 UTC | |
by stevieb (Canon) on Sep 15, 2015 at 22:54 UTC |