Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I ma trying to retrive the array value from a hash using the refernce
my $event_method=$event_ref->[0]; --$event_ref is an array reference #print $event_method; my @file_details=@{$event_file -> {$event_method}}; --$event_file is an hash reference print "@file_details";
if i hard code the value to
my @file_details=@{$event_file -> {gsm}};
i get the desired out put. I have printed the $event_method value and that also retrived correctly. I am not bale to debug the error please guide me. Thanks in advance

Replies are listed 'Best First'.
Re: retriving array value from hash refernce
by jethro (Monsignor) on Jun 30, 2010 at 11:22 UTC

    Maybe that value you store into $event_method has still a "\n" value at the end (for example if you read it from a file and didn't use chomp) or some other invisible character in it.

    The best way to find out things like that is to use Data::Dumper, i.e.:

    use Data::Dumper; $Data::Dumper::Useqq=1; #invisible characters are shown print Dumper($event_method);
      hi use of Dumper gave me out put
      test_script.pl $VAR1 = "gms";
      which shows it is correclty retrived rt?
        yes, but it is "gms" and not "gsm" which is what you gave as the correct string