in reply to Re: Populating a hash from array
in thread Populating a hash from array

what is the syntax for slicing a hash -reference-?
@{$href}{@keys}

Replies are listed 'Best First'.
Re: Re: Re: Populating a hash from array
by ysth (Canon) on Jan 06, 2004 at 06:56 UTC
    If the reference is a simple scalar, you can just say @$href{@keys}. The curly braces around the reference are only necessary if the reference is a more complicated expression (e.g. @{gimme_href()}{@keys}).

    Same thing goes with using a slice or $# (last index) on an array reference: @$aref[@indices] and $#$aref or @{gimme_aref()}[@indices] and $#{gimme_aref()}.

    Of course, if the curlies make it more clear to you, by all means use them.