why Perl complaints my script
- From: chen_li3@xxxxxxxxx (Chen Li)
- Date: Thu, 28 Sep 2006 05:43:47 -0700 (PDT)
Hi all,
I write a small script for permutation. When I use
version 1) Perl always complaint it although I get the
result. If I use version 2) it never says a word about
it. Any comments?
Thank you in advance,
Li
####version 1)###
use strict;
use warnings;
print permutation(5,2); # 5 choose 2
exit;
#subroutine permutation
sub permutation{
my ($n, $k)=@_;
my $result=1;
for ($k; $k>=1;$k--) {$result*=$n--;}#line 15
return $result;
}
#####screen output####
Useless use of private variable in void context at
fac1.pl line 15.
20
####version 2)###
use strict;
use warnings;
print permutation(5,2); # 5 choose 2
exit;
#######subroutine permutation##########
sub permutation{
my $n=shift;
my $result=1;
for (my $k=shift; $k>=1;$k--) {$result*=$n--;}
return $result;
}
###screen output####
20
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
.
- Follow-Ups:
- Re: why Perl complaints my script
- From: Paul Lalli
- Re: why Perl complaints my script
- From: nobull67@xxxxxxxxx
- Re: why Perl complaints my script
- From: Dr.Ruud
- Re: why Perl complaints my script
- From: Adriano Ferreira
- Re: why Perl complaints my script
- From: Igor Sutton
- Re: why Perl complaints my script
- Prev by Date: cgi script
- Next by Date: Re: why Perl complaints my script
- Previous by thread: cgi script
- Next by thread: Re: why Perl complaints my script
- Index(es):