in reply to Re^3: I have a perl snippet. And I need help understanding it. Can you help answer these questions.
in thread I have a perl snippet. And I need help understanding it. Can you help answer these questions.
"It depends" (as the professors in my Economics classes liked to say).
If $obj->{$j}->{rxABC} holds a scalar value, you should be able to print it like this:
print "Found: $obj->{$j}->{rxABC}\n";
That reminds me. Anytime you have a -> between two brackets you can omit it. So that becomes:
print "Found: $obj->{$j}{rxABC}\n";
On the other hand, if $obj->.....{rxABC} holds a reference to another layer (an array ref or hash-ref, for example), you will need to deal with that layer too. Fortunately Perl can print an array in a sensible way. So let's say that {rxABC} holds an array ref like this:
$obj->{$j}{rxABC} = ['a', 'b', 'c'];
Then you would need to dereference that array ref to make sense of it too. Here's one way:
print "Found: ", join( ' ', @{ $obj->{$j}{rxABC} } ), "\n";
Or another way:
print "Found: @{$obj->{$j}{rxABC}}\n";
Dave
|
|---|