seek.pl <pattern> <glob> <editor>
Seek recursively for <pattern> in the <glob> files and edit found lines in <editor>.
Copyright 2000-2007 Etienne LEMEE <coding AT etilem DOT net>
This piece of code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
#!/usr/bin/perl -w use strict; @ARGV > 2 or die << "USAGE"; usage: $0 <pattern> <glob> <editor> seek recursively for <pattern> in the <glob> files and edit found lines in <editor> USAGE my ($pat, $glo, $tmp) = @ARGV; my $edi = qx! which $tmp ! or die "Can't find '$tmp' on your system !"; chomp $edi; for my $file (qx! find -type f -name '$glo' !) { # Yes, I've been told about File::Find ;) chomp $file; open my $fh, '<', $file; while (<$fh>) { system "$edi +$. $file" if (/$pat/); } close $fh; }