use warnings; use strict; my $curUrl = "http://localhost:8080"; my $tarUrl = "http://localhost"; opendir DIR, $ARGV[0] or die "Could not open directory"; my @files = grep { -f $_ } readdir DIR; foreach (@files) { open FILE, "+>", "$ARGV[0]\\$_" or die "Could not open file -- $_"; while (my $line = ) { $line =~ s/$curUrl/$tarUrl/g; } close FILE; } closedir DIR;