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

Hello all, as I told before, I'm newbie in Perl, that I'm studing throw Lama Book. I have an error in an excercise and I don't understand that error: This is the code:
use strict; sub askName { chomp(my $nome=<STDIN>); my %nomi=( "fred"=>'flinstone', "barney"=>'rubble', "wilma"=>'flinstone' ); for (%nomi) { print $_ if ($nomi{$_} eq $nome); } } &askName;
Why Have I: "Use of uninitialized value in string eq " ?

Replies are listed 'Best First'.
Re: Use of uninitialized value in string eq
by FunkyMonk (Bishop) on Feb 20, 2010 at 11:11 UTC
    for (%nomi) {

    This will loop over all the keys and values of your hash. What you want is:

    for (keys %nomi) {

      Thank you for your answer. I understood my error, the unitialized string was the hash value.