K
kielhd
Hi NG,
I want to search the keys of the hash %z for the value of $x. If $x
matches $i (line 9), a string should be printed.
$x matches key "Hallo", but there is no output!
Where is my mistake?
Thanks in advance
Henning
01 #!C:/Perl/bin/perl.exe -w
02 $x = "all";
03 %z = (
04 "Ich" => "1",
05 "Du" => "2",
06 "Hallo" => "3"
07 );
08 foreach $i ( keys %z ) {
09 if ( $x =~ /$i/ ) { print "$x is part of $i ...\n"; }
10 }
I want to search the keys of the hash %z for the value of $x. If $x
matches $i (line 9), a string should be printed.
$x matches key "Hallo", but there is no output!
Where is my mistake?
Thanks in advance
Henning
01 #!C:/Perl/bin/perl.exe -w
02 $x = "all";
03 %z = (
04 "Ich" => "1",
05 "Du" => "2",
06 "Hallo" => "3"
07 );
08 foreach $i ( keys %z ) {
09 if ( $x =~ /$i/ ) { print "$x is part of $i ...\n"; }
10 }