On Wed, 2008-12-10 at 21:41 +0530, Anirban Adhikary wrote: > DEAR List > Is it possible what i am looking from the following code > > my @merge_err=("a","b","c","d","e"); > my @dup_err=("1","2","3","4","5"); > my @load_err=("aa","bb","cc","dd","ee"); > print "Enter Value:-[load/merge/dup]\t"; > > > ##(for the sake of simplicity I am thinking user will give input between > these values)########## > > chomp(my $option = lc <STDIN>); > my $err=$option."_"."err"; > > > Now here lies my question Is it possible to convert $err into any of the > above mentioned array/arrays according to user input? Is it possible? > > So that i can print the values of the above array/arrays in a foreach loop? > > Thanks & Regards in advance > Anirban Adhikary.
my %Errors = ( merge => [ 'a', 'b', 'c', 'd', 'e', ], dup => [ '1', '2', '3', '4', '5', ], load => [ 'aa', 'bb', 'cc', 'dd', 'ee', ], ); print "Enter option: "; chomp( my $option = lc <STDIN> ); if( exists $Errors{$option} ){ for my $err ( @{ $Errors{$options} } ){ print "$err\n"; } }else{ die "invalid option: $option\n"; } -- Just my 0.00000002 million dollars worth, Shawn The key to success is being too stupid to realize you can fail. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/