richill has asked for the wisdom of the Perl Monks concerning the following question:
perl filefind.pl testDir
i get the error message
couldn't open the file testDir .... ! No such file or directory at filefind.pl line 44.
couldn't open the file testDir/.DS_Store .... ! No such file or directory at filefind.pl line 44.
couldn't open the file testDir/nitcnitc Folder .... ! No such file or directory at filefind.pl line 44.
I think the problem is due to the find module but Im not sure how to use it correctly in this case. What am I doing wrong please.
#!/usr/local/bin/perl -w # force taint checks, and print warnings #use strict; # install all three strictures # program to open files in a directory and change directory paths fro +m oldpath to $newpath # use stat function to mke file handles available $|++; # force auto flush of output buffer use File::Find; #define full path to folder my $path = " /users/hill/desktop/test_src/"; my $newpath = "/library/webserver/documents/siteroot/installfolder/"; #define string my $newString = 'newDir/newFile'; my $oldString = 'oldDir/oldFile'; # define arrays my @ListofFiles; #define string directory as <STDIN> my $Start_dir = shift or die "usage: $0 <start_dir>\n"; unless (-d $Start_dir){ die "Start directory .'$Start_dir' . is not a directory.\n"; } find(\&process, $Start_dir); sub process{ my $content = ''; # add filename to ListofFiles push(@ListofFiles, $File::Find::name); my $fileopened = $File::Find::name; unless (open FILEOPENED, $fileopened ) { warn "couldn't open the file $fileopened .... ! $!"; return; } my $data =join '', <FILEOPENED>; close(FILEOPENED); return unless $data; print "file is :: $File::Find::name\n"; print "found the file $fileopened \n\n reading the following data \n\ +n $data\n\n\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why doesnt the string returned by $File::Find::name find point to files
by Thelonius (Priest) on Apr 26, 2006 at 23:40 UTC | |
|
Re: Why doesnt the string returned by $File::Find::name find point to files
by jacques (Priest) on Apr 26, 2006 at 23:40 UTC | |
|
Re: Why doesnt the string returned by $File::Find::name find point to files
by GrandFather (Saint) on Apr 26, 2006 at 23:53 UTC | |
by richill (Monk) on May 06, 2006 at 10:40 UTC | |
|
Re: Why doesnt the string returned by $File::Find::name find point to files
by ww (Archbishop) on Apr 27, 2006 at 15:43 UTC |