in reply to Dereference array via STDIN

Rather than trying to input a variable name, perhaps it might be simpler to input a hash key and store your data in a Hash-of-hashes:
use warnings; use strict; use Data::Dumper; my %hoh = ( cs101 => { joe => 80 }, cs102 => { moe => 90 } ); print "Choose which hash\n"; chomp (my $input = <STDIN>); if (exists $hoh{$input}) { my %hash = %{ $hoh{$input} }; # dereference hash print Dumper(\%hash); } else { print "$input not found\n"; } __END__ Choose which hash cs101 $VAR1 = { 'joe' => 80 };

Replies are listed 'Best First'.
Re^2: Dereference array via STDIN
by AnomalousMonk (Archbishop) on Oct 11, 2008 at 04:20 UTC
Re^2: Dereference array via STDIN
by gctaylor1 (Hermit) on Oct 12, 2008 at 02:09 UTC
    Thanks everyone for the replies. I have some reading to do.