rupesh has asked for the wisdom of the Perl Monks concerning the following question:

Hi Guys,
I've been working with perl all day, maybe im not thinking right but could you guys tell the mistake i made
$path=`cd`; print $path; my %files = Recurse(["$path"], { match => '\.', nomatch => '' }); foreach (sort keys %files) { print; foreach (@{ $files{"$_"} }) { $files=$_; my $fullname="$dirs"."\\"."$files"; print $fullname; } }

Here's the error message: Unsuccessful stat on filename containing newline at C:/Perl/lib/File/Find.pm lin e 608.
Thanks

we're born with our eyes closed and our mouths wide open, and we spend our entire life trying to rectify that mistake of nature. - anonymous.

Replies are listed 'Best First'.
Re: Directory Recursion Question
by Abigail-II (Bishop) on Aug 06, 2003 at 12:23 UTC
    Did you look up the warning you got in man perldiag? It's explained there. I can't see anything in your code fragment that calls anything in File::Find, so it's unclear to me what relevance your code fragment has.

    Abigail
    --
    P.S., fix your sig. You aren't closing your italics.


      Ok.. but i do use File::Recurse; and File::Find; in the beginning of my script.
      Thanks

      we're born with our eyes closed and our mouths wide open, and we spend our entire life trying to rectify that mistake of nature. - anonymous.
        you should use
        use Cwd; my $path = cwd;
        or at least chomp($path)
Re: Directory Recursion Question
by graff (Chancellor) on Aug 07, 2003 at 02:49 UTC
    On any unix system,  $path = `cd`; would set $path to an empty string. If it produces a non-empty string on your system, this string almost certainly includes the line termination ("\n", or "\r\n" or whatever). Anyway, use the Cwd module to set $path.