in reply to Finding files in a directory tree from and array of file names

Can you tell us what you mean by "not working"? What behaviour were you expecting that you're not seeing?

You may find more clues to what is actually going on if you used -w and use strict in your script.

Blessed Be
The Pixel

  • Comment on Re: Finding files in a directory tree from and array of file names

Replies are listed 'Best First'.
Re: Re: Finding files in a directory tree from and array of file names
by Anonymous Monk on Oct 15, 2001 at 15:25 UTC
    By "not working" I mean that nothing is being displayed by the print command.
    Using use strict I get the following errors...
    Global symbol "$srcfile" requires explicit package name at D:\Projects +\perl\recurse.pl line 26. Global symbol "$srcfile" requires explicit package name at D:\Projects +\perl\recurse.pl line 34. Execution of D:\Projects\perl\recurse.pl aborted due to compilation er +rors.
    What exactly does this mean?

      Your @sourcefiles array contains $File::Find::name for each of the found files. This is the full pathname of the file.

      Later you check these values against the filename in $_. This only contains thea actual name of the file so your match will never work.

      strict turns on a number of constraints that will make your Perl scripts better. One of the most useful is that it forces you to think about variable scoping and predeclare variables. This is most often done using my. That's the error that you're seeing.

      I didn't really expect you to just add the line without reading the documentation first :-)

      Blessed Be
      The Pixel