in reply to Re: using file::find::name and file tests
in thread using file::find::name and file tests

the File::Find docs (and a quick warn tossed into OP's first code) say that $File::Find::name is the 'Complete pathname to the file', and not relative and all the examples given in the The wanted function section indicate the same thing..

to OP-- you can add some debugging to print out cwd, $_, and $File::Find::name to examine exactly what's going on..

Replies are listed 'Best First'.
Re^3: using file::find::name and file tests
by bart (Canon) on May 06, 2006 at 20:28 UTC
    the File::Find docs (and a quick warn tossed into OP's first code) say that $File::Find::name is the 'Complete pathname to the file', and not relative and all the examples given in the The wanted function section indicate the same thing..
    Let's recap... yes it is the complete path, but constructed from the original parameter. If you start with ".", your path will look something like "./path/to/file" which, as merlyn said, won't work as the cwd is changed to the directory the current file is in, every time.

    So, if you want an absolute path, start out with absolute paths. rel2abs from File::Spec::Functions can do wonders. You don't have to use in it the callback, just apply it to every parameter you pass to find.

    use File::Spec::Functions 'rel2abs'; find sub { blah blah } map rel2abs($_), @dirs;
    Now you'll get absolute paths.
      I get it now.. I tried it before running OP's code with '/tmp' as the param .. running w/'.' shows the issue..

      Is it just me or is that not clear in the docs? Maybe i was just getting thrown by the absolute paths used in the example chart...


      Anyways, i second the note from my other reply about File::Find::Rule :) (or merlyn's File::Finder; both obsolete OP's issue)
Re^3: using file::find::name and file tests
by richill (Monk) on May 07, 2006 at 21:40 UTC
    what is an OP?

      "Original poster", in this case you.

      --
      David Serrano

      or, "Original Post".