On 9/6/2005 4:50 PM Gergely Buday wrote:

Hi there,
do you have a clue why is this not working? The interpreter complains
about a syntax error in line 7 near $myhash.

Seems like you are confused with the brackets...

#!/usr/bin/perl

%myhash = { "alma" => "apple", "korte" => "pear" };

Should be

%myhash = ( "alma" => "apple", "korte" => "pear" );

foreach $ky (keys (%myhash))

No need for any brackets around the hash

foreach $ky (keys %myhash)

{
        print $ky, ":" , $myhash($ky), "\n";

Should be

          print $ky, ":" , $myhash{$ky}, "\n";

}

HTH...

--
Ankur

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to