Home  |  Linux  | Mysql  | PHP  | XML
From:Jatin Davey Date:Fri Sep  3 05:09:13 2010
Subject:Traversing Hash printing two times
Hi

I am a newbie to Perl , I have this piece of code :

*CODE:*

#!/usr/bin/perl
use warnings;
use strict;

my @english = qw(january february march april may june july);
my @french = qw(janvier fverier mars avril mai juin juily);

my %months;
my $eng_ref;
my $fre_ref;

$eng_ref = \@english;
$fre_ref = \@french;

$months{english} = $eng_ref;
$months{french} = $fre_ref;

for (keys %months) {
print "Months in english : @{$months{english}} \n";
print "Months in french : @{$months{french}} \n";
}


*OUTPUT:*

Months in english : january february march april may june july
Months in french : janvier fverier mars avril mai juin juily
Months in english : january february march april may june july
Months in french : janvier fverier mars avril mai juin juily


*Question*

Why do i get the array that i wanted two times ?
i have just added two keys into the hash then why do i get the values
two times.

Please explain me this.

Thanks
Jatin

Navigate in group perl.beginners at sever nntp.perl.org
Previous Next


Your recent visits
Re: Need help with Mail::Sender
Re: Traversing Hash printing two times
Re: Traversing Hash printing two times
Re: Traversing Hash printing two times
Re: Flip-flop conversations using Socket



  
© No Copyright
You are free to use Anything, but please consult your advocate before doing so as this website
also list content from other sources which may be copyrighted.
Site Maintained by Zareef Ahmed
Powered By PHP Consultants