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)[EMAIL PROTECTED];
        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 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to