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

  • Thread starter George R. Gonzalez
  • Start date
G

George R. Gonzalez

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;
}
 
B

Brian McCauley

George R. Gonzalez said:
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\\
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top