in reply to Re: Processing All Files in a Directory Recursively under Windows OS
in thread Processing All Files in a Directory Recursively under Windows OS

First thanks for your reply, if i run from the command line
X:\>perl -MFile::Find -le "sub process_file{print $File::Find::name if + -f };find (\&process_file,'test with whitespace')"
it works perfectly, the problems came when the I am using it in a file with variables, means :
use File::Find; print "Enter your root directory\n"; $root = <STDIN> ; sub process_file{ print $File::Find::name if -f ; } find (\&process_file,$root);
%> a.pl Enter your root directory: D:\DBS %> Can't state D:\DBS

Any idea what is the reason for this failure ?

Thanks in advance
Azaria

20070918 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips

Replies are listed 'Best First'.
Re^3: Processing All Files in a Directory Recursively under Windows OS
by Corion (Patriarch) on Sep 17, 2007 at 10:49 UTC

    Please use proper HTML formatting and preview your node before you post it.

    Your variable $root is not what you think it is. Print it out like this:

    my $root = "Hello world"; print "Root is >>$root<<\n";

    In your case, when you read $root from STDIN it has a newline appended to it. You should remove that by using the chomp function:

    chomp $root;