Re: why Perl complaints my script
- From: "nobull67@xxxxxxxxx" <nobull67@xxxxxxxxx>
- Date: 28 Sep 2006 10:48:18 -0700
Chen Li wrote:
for ($k; $k>=1;$k--) {$result*=$n--;}#line 15
Useless use of private variable in void context at
fac1.pl line 15.
Well that's fairly clear isn't it?
And if it's not, what part of the explaination of that message in the
reference manual did you find unclear? Remember as a beginner you are
in a unique postion to tell us where the manuals are unclear. We can't
tell because we know what it's trying to say already. So, please,
whenever you find something hard to understand, cite the _exact_
passage of the manual that you are having trouble with so that we get a
chance to improve it.
<fish>
Note that "private" here is a rather odd choice of word, the word we
usually use in perl is "lexical".
What the warning is telling you is that your code is exactly the same
as
for ( ; $k>=1;$k--) {$result*=$n--;}#line 15
The first expression in for(;;) is there only for the sake of its side
effects. The expression is evaluated in such a way that is doesn't have
a return value. This is called evaluating the expression in a void
context. The expression $k has no side effects so evaluating it a void
context is, to quote the warning, "useless".
</fish>
.
- References:
- why Perl complaints my script
- From: Chen Li
- why Perl complaints my script
- Prev by Date: hash slices
- Next by Date: Re: cgi script
- Previous by thread: Re: why Perl complaints my script
- Next by thread: Re: why Perl complaints my script
- Index(es):
Relevant Pages
|