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

Discussion in 'Perl Misc' started by George R. Gonzalez, Aug 8, 2003.

  1. 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;
    }
     
    George R. Gonzalez, Aug 8, 2003
    #1
    1. Advertising

  2. "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\\
     
    Brian McCauley, Aug 8, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tom Reilly
    Replies:
    5
    Views:
    440
    Gavin Kistner
    Nov 24, 2005
  2. jon rogers
    Replies:
    3
    Views:
    269
    Eric J. Roode
    Dec 4, 2003
  3. makko
    Replies:
    2
    Views:
    2,454
    makko
    Sep 19, 2005
  4. Marek
    Replies:
    24
    Views:
    750
    Dr.Ruud
    Jun 16, 2007
  5. Replies:
    7
    Views:
    187
    Peter J. Holzer
    Dec 15, 2007
Loading...

Share This Page