#!/usr/local/bin/perl -w # print warnings use strict; # install all three strictures # program to open files in a directory and change directory paths from oldpath to $newpath # use stat function to mke file handles available $|++; # force auto flush of output buffer use File::Find; use Cwd; use File::Path; my @ListofFiles; my $Start_dir = shift or die "usage: $0 \n"; #define string directory as # scan recursivley from the start directory unless ( -d $Start_dir ) { die "Start directory .'$Start_dir' . is not a directory.\n"; } sub wanted { my $fileopened = $File::Find::name; my $fileout = "$fileopened.NEW2"; if ( -e $fileopened ) { #print "Found $File::Find::name\n"; } if ( -T $fileopened ) { #print "$File::Find::name is a DATA file\n"; push( @ListofFiles, $fileopened ); } else { #print "Didn't OPEN $File::Find::name\n"; } } sub searchfiles () { my $a; #print "$fileout\n"; foreach $a (@ListofFiles) { print "$a\n"; ( open FILEOPENED, "$a" ) or die "couldn't open the file $!"; while () { print "file is opened for reading"; } close(FILEOPENED); } } find( { wanted => \&wanted, no_chdir => 1 }, $Start_dir ); searchfiles();