I have a class with a method that returns a hash. Ordinarily, I would get the result like so:
%resp = $myclass->sub($foo);
And then access members of the returned hash like this:
$resp{key}{subkey};
in the case of a 2d hash.
I figure there must be a way to combine this into a single, elegant line, something like this:
$myclass->sub($foo)->{key}{subkey}
This obviously is not dereferenced properly as Perl returns this when trying to run the code:
Can't use string ("1/8") as a HASH ref
In trying random dereferencing sequences, from looking "References quick reference" on Perlmonks, I came up with the following, which Perl does not complain about, but also does not return what I'm looking for:
$%{$myclass->sub($foo)}->{key}{subkey}
Can somebody tell me what the magic dereferencing escape sequence is to do this?