I think a better way to recursively process all files would be to pass your processing subroutine as a code reference to File::Find.
use warnings; use strict; use File::Find my $curUrl = "http://localhost:8080"; my $tarUrl = "http://localhost"; sub process_files { next unless -f $File::Find::name; print "Processing $File::Find::name\n"; open FILE, "+>", $File::Find::name or die "Could not open file $File::Find::name"; while (my $line = <FILE>) { $line =~ s/$curUrl/$tarUrl/g; } close FILE; } find( &process_files, $ARGV[0] );
It is a bit old school perl, but sometimes I find the old tools are the best.
In reply to Re: Searching and Replacing file content within directory
by chrestomanci
in thread Searching and Replacing file content within directory
by King0
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |