in reply to Print value from hash

Your code declares a hash of arrays:
print $name{$search}[0], "\n";
or
my @array = @{$name{$search}};

Replies are listed 'Best First'.
Re^2: Print value from hash
by stevieb (Canon) on Sep 25, 2015 at 22:44 UTC

    Not taking away from your insight, but I think it's important for future readers of any code to see where de-referencing begins.

    perl always knows when anything in a (hash) structure is another structure and allows you to not require the deref operator (->) because it's implicit, but I'd recommend putting such in the path where dereferencing starts:

    print "$name{$search}->[0]\n";

    Easier to spot where things become a reference at a glance.

    -stevieb