This is all that you need:

use strict ;
my %hash = ("sky", "blue", "grass", "green", "apple", "red") ;
while(my($key, $val) = each(%hash)){
        print("$key ==> $val\n");
}

-----Original Message-----
From: Neclos [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 22, 2001 3:13 PM
To: [EMAIL PROTECTED]
Subject: create hash and print all elements?


I need to create a hash with fixed elements and print all elements.  I
keep getting  errors when I try to run what I put together.  I commented
out the different ways I tried to run the print.  Now I have no clue
what to try next.

use strict ;

%hash = ("sky", "blue", "grass", "green", "apple", "red") ;
@hash_list = %hash ;
my $k ;
my $hash ;
my %hash ;

# my $temp = %hash;

#    print "$temp";

# print "@{[ %hash ]}\n";

foreach $k (sort keys %hash) {
    print "$k => $hash{$k}\n";
}

exit 0 ;

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to