in reply to RE: Re: Still problems with recursive coding.
in thread Still problems with recursive coding.

That is a much easier way of doing it. One question, how do you set the flags you are talking about?
I also took a look at the else statements I wrote and you are correct. Why do I want to print out the statement once for everyfile that does not match? So I corrected protion of the code. Once again you are the man, thanks.
curtisb
  • Comment on RE: RE: Re: Still problems with recursive coding.

Replies are listed 'Best First'.
RE: RE: RE: Re: Still problems with recursive coding.
by Fastolfe (Vicar) on Nov 14, 2000 at 02:38 UTC
    For brevity's sake:
    my $found_any = 0; ... sub search_all { unlink, $found_any++ if /.../; } # (repeat for search_none) print "No files found!\n" unless $found_any;
    Make sense? You basically set a flag (a variable) if you find anything to unlink, and when your script is completed, check to see if this variable has a value, and if it doesn't, that means nothing matched, and you can alert the user to this fact. You can go the other way as well:
    if ($found_any) { print "$found_any files deleted.\n"; } else { print "No files were found to delete.\n"; }
      Thanks, Fastolfe! I'm still new at this. Trying to learn as fast as I can. Thanks. Curtisb