Horst: Hash übergeben; for %hash

Beitrag lesen

Hi

eine Frage hätte ich noch

ich möchte nach der Schleife überprüfen ob es ein bestimmtes Element im hash gibt und ob er nicht leer ist

exists EXPR
            Given an expression that specifies a hash element or array
            element, returns true if the specified element in the hash or
            array has ever been initialized, even if the corresponding value
            is undefined. The element is not autovivified if it doesn't
            exist.

print "Exists\n"    if exists $hash{$key};
                print "Defined\n"   if defined $hash{$key};
                print "True\n"      if $hash{$key};

print "Exists\n"    if exists $array[$index];
                print "Defined\n"   if defined $array[$index];
                print "True\n"      if $array[$index];

usw. Siehe perldoc -f exists und auch Struppies Antwort.

Viel Spass noch,
Hotte