Hi when I run this code

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"; }

In reply to Why doesnt the string returned by $File::Find::name find point to files by richill

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.