#!/usr/bin/perl -w use strict; use warnings; use Fcntl qw( :seek ); use IO::Handle; use FileHandle; use File::Find; my $root = shift( @ARGV ); unless ( $root and ( -d $root)) { usage(); exit( 1 ); } my %args = ( "wanted" => \&process, "no_chdir" => 1, ); File::Find::find( \%args, $root ); exit( 0 ); sub process { my $path = $_; if ( $path !~ /htm?$/i) { return; } my $fh = new FileHandle( $path, "r+" ); unless ( $fh ) {return;} my $data = join( "", $fh->getlines() ); my $spat = 'gmx.de'; my $rpat = 'yahoo.de'; unless ( $data =~ s~$spat~$rpat~g) { $fh->close(); return; } seek( $fh, 0, SEEK_SET ); truncate( $fh, 0); $fh->print( $data); $fh->close(); } sub usage { STDERR->print("usage: $0\n" ); }