in reply to using filehandle to open files listed in array

sub wanted { my $fileopened = $File::Find::name;
I don't think you want this combination. $File::Find::name is the path including any parent directories, but you're already chdir'ed into the directory containing the file. Inside wanted, you want to use $_. After the execution is complete, you'll want $File::Find::name.

More specifically, when you're thinking about "a/b/c.txt", you're already in the directory "a/b", so trying to open "a/b/c.txt" is wrong now. You want just c.txt, which is in $_. Review the thread beginning in "using file::find::name and file tests". (update: oh, that was you. apparently you didn't learn anything from the other posts!)

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re^2: using filehandle to open files listed in array
by richill (Monk) on May 14, 2006 at 20:17 UTC

    Im hopelessly confused. I thought that using find( { wanted => \&wanted, no_chdir => 1 }, $Start_dir );

    would mean that I don't change directories inside wanted so I could use $File::Find::name.

    I dont want to waste anyones time so I'm going to reread the post again and again until I get it..

      The problem is that when you try to open the files you are not in $Start_dir so you have to prepend that to the file name like:
      open FILEOPENED, "$Start_dir/$a" or die "couldn't open the file $!"