Re: Traversing Hash printing two times

2010-09-02 Thread Uri Guttman
> "JG" == Jim Gibson writes: JG> At 11:29 AM +0530 9/3/10, Jatin Davey wrote: >> Any reason to use named variables than to use the default variable ($_) ? JG> Two reasons that I know: JG> 1. If you use a named variable, you and everybody else reading your JG> code will know what i

Re: Traversing Hash printing two times

2010-09-02 Thread Uri Guttman
> "JWK" == John W Krahn writes: JWK> Uri Guttman wrote: >>> "JD" == Jatin Davey writes: >> >> >> but it isn't as good as my code. don't use $_ unless you have to (as in >> >> map/grep). it is much better to use named variables. JD> Any reason to use named variables than to

Re: Traversing Hash printing two times

2010-09-02 Thread John W. Krahn
Uri Guttman wrote: "JD" == Jatin Davey writes: >> but it isn't as good as my code. don't use $_ unless you have to (as in >> map/grep). it is much better to use named variables. JD> Any reason to use named variables than to use the default variable ($_) ? yes, you can read the co

Re: Traversing Hash printing two times

2010-09-02 Thread Jim Gibson
At 11:29 AM +0530 9/3/10, Jatin Davey wrote: Any reason to use named variables than to use the default variable ($_) ? Two reasons that I know: 1. If you use a named variable, you and everybody else reading your code will know what it is for. While it doesn't matter much for 3-line loops, s

Re: Traversing Hash printing two times

2010-09-02 Thread Jatin Davey
yes, you can read the code and see what the variable is for. $_ is useful in some situations but not for foreach loops and similar things. names are important in code and $_ has no name. you lose the opportunity to tell the reader of the code what the variable contains and what it is used for.

Re: Traversing Hash printing two times

2010-09-02 Thread Uri Guttman
> "JD" == Jatin Davey writes: >> but it isn't as good as my code. don't use $_ unless you have to (as in >> map/grep). it is much better to use named variables. JD> Any reason to use named variables than to use the default variable ($_) ? yes, you can read the code and see what the var

Re: Traversing Hash printing two times

2010-09-02 Thread Jatin Davey
but it isn't as good as my code. don't use $_ unless you have to (as in map/grep). it is much better to use named variables. Any reason to use named variables than to use the default variable ($_) ? and please learn to edit quoted emails and to bottom post. you can google for what that means.

Re: Traversing Hash printing two times

2010-09-02 Thread Uri Guttman
> "JD" == Jatin Davey writes: JD> for (keys %months) { JD> print "Months in $_ : @{$months{$_}} \n"; JD> } JD> and it worked fine. but it isn't as good as my code. don't use $_ unless you have to (as in map/grep). it is much better to use named variables. JD> On 9/3/2010 10:47

Re: Traversing Hash printing two times

2010-09-02 Thread Jatin Davey
Changed it to: #!/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; $months{english} = \...@english; $months{french} = \...@french; for (keys %months) { print "Months in

Re: Traversing Hash printing two times

2010-09-02 Thread Uri Guttman
> "JD" == Jatin Davey writes: JD> #!/usr/bin/perl JD> use warnings; JD> use strict; very good to see those. JD> my @english = qw(january february march april may june july); JD> my @french = qw(janvier fverier mars avril mai juin juily); JD> my %months; JD> my $eng_ref; JD>

Traversing Hash printing two times

2010-09-02 Thread Jatin Davey
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; $