#!/usr/bin/env perl use warnings; use strict; my $curUrl = "http://localhost:8080"; my $tarUrl = "http://localhost"; my @buf; my ($line, $f); sub diveinto { print "dive into: $_[0]\n"; opendir DIR, $_[0] or die "Could not open directory"; my @files = readdir DIR; closedir DIR; foreach $f (@files) { if ($f =~ /\.{1,2}/) {next } print "processing: $f\n"; if ( -d "$_[0]/$f" ) { diveinto ("$_[0]/$f") } else { open FILE, "<". "$_[0]/$f" or die "Could not open file -- $_[0]/$f"; @buf = ; close FILE; open W, ">" . "$_[0]/$f" or die "cunt open for r/w -- $_[0]/$f"; foreach $line (@buf) { $line =~ s/$curUrl/$tarUrl/g and print "Yes"; print W $line; } close W; } } } diveinto $ARGV[0];