Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Useless use of private variable in void context ... ?

Reply
Thread Tools

Useless use of private variable in void context ... ?

 
 
George R. Gonzalez
Guest
Posts: n/a
 
      08-08-2003


I get:
Useless use of private variable in void context at b.pl line 588,
which is the last line of this sub, '$A", the returned value.

The weird thing is this has been working fine for weeks,
now it starts to complain!

Any ideas?



sub LookForDirLo{ my( $pat, $Base ) = @_; my( @D, $f, $fn, $A );
$A = '';
##print "lookfordirlo of '$Base'\n";
if( $Base =~ /$pat/i ) { $A = $Base; print "Setting A to '$A'" }
else {
if( -d $Base ) {
if( -r $Base ) {
if( opendir( DIR, $Base ) ) {
@D = readdir( DIR ); closedir( DIR );
if( scalar @D == 0 ) { Warn "Empty directory info returned for
'$Base'" }

foreach $f ( @D ) {
if( $A eq '' ) {
if( $f eq '.' or $f eq '..' ) { }
else {
$fn = "$Base\\$f";
if( -d $fn ) { $A = LookForDirLo( $pat, $fn ) }
}
}
}

}
else { Warn "opendir failed: Cant grovel in folder '$Base', System said:
'$!'" }
} else { Warn "LookForDirLo found that '$Base' is not readable!" }
} else { Warn "LookForDirLo found that '$Base' is not a directory!" }
$A;
}



 
Reply With Quote
 
 
 
 
Brian McCauley
Guest
Posts: n/a
 
      08-08-2003
"George R. Gonzalez" <> writes:

> Useless use of private variable in void context at b.pl line 588,
> which is the last line of this sub, '$A", the returned value.


No it isn't. Look again at your code again. The {...} in the
fragment you post are mismatched. But, assuming your whole program
compiles at all, there is a complementary mismatch further on.

We say in the posting guidelines:

First make a short (less than 20-30 lines) and *complete* program
that illustrates the problem you are having. People should be able
to run your program by copy/pasting the code from your article. (You
will find that doing this step very often reveals your problem
directly. Leading to an answer much more quickly and reliably than
posting to Usenet.)

We were not kidding. We really mean this. It really works.

What I did to find your mistake is _exactly_ what the guidelines above
told you to do before you posted (I didn't count the {...} by hand).

Had you followed the guidelines you would, indeed, have found the
solution for yourself.

--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
not sure why I am getting the following warning "Useless use of aconstant in void context" mcardeiro@yahoo.com Perl Misc 7 12-15-2007 09:15 PM
Useless use of array element in void context Marek Perl Misc 24 06-16-2007 02:39 PM
syntax error warning: useless use of a variable in void context Tom Reilly Ruby 5 11-24-2005 04:05 AM
Useless use of a constant in void context makko Perl Misc 2 09-19-2005 01:18 PM
Useless use of private variable in void context at parser.cgi line 48. jon rogers Perl Misc 3 12-04-2003 12:21 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57