| |
| sub walk { |
| my $dir = shift; |
| opendir(DIR, $dir) or die $!; |
| my @files = readdir DIR; |
| closedir DIR; |
| for $fdir ( @files ) { |
| next if( $fdir =~ /^\./ ); |
| if( -d "$dir/$fdir" ) { |
| walk( "$dir/$fdir" ); |
| } elsif( !-d "$dir/$fdir" ) { |
| apply( "$dir/$fdir" ); |
| } |
| } |
| } |
| |
| sub apply { |
| my $f = shift; |
| return if( $f =~ /.avi$/ ); |
| return if( $f =~ /.pdf$/ ); |
| return if( $f =~ /temp.pl$/ ); |
| open FILE, "$f" or die $!; |
| $whole = join "", <FILE>; |
| close FILE; |
| if( $whole =~ /projects\/projects/ ) { |
| print "$f\n"; |
| |
| ($filename) = $f =~ /.*\/(.*)/; |
| |
| $whole =~ s/projects\/projects/projects/g; |
| |
| open FILE, ">$f" or die $!; |
| print FILE $whole; |
| close FILE; |
| } |
| } |
| |
| walk( "." ); |