> "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
> "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
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
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
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.
> "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
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.
> "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
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
> "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>
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;
$
11 matches
Mail list logo