in reply to changing inside a file
In that case, I would think somewhat in this direction:
But I must admit that I haven't actually put this to a test, I only made sure it compiles. It's just to give you some ideas.my @todo = glob('c:/*.inc'); # some kind of file my %done; undef $/; while(@todo) { my $file = shift @todo; open FILE, "+<$file" or die "Can't open file $file: $!"; $_ = <FILE>; # whole contents of file if(s/\bold\b/new/g) { # replace contents of file seek FILE, 0, 0; truncate FILE, 0; print FILE; } my($dir) = $file =~ m[(.*/)]; while(/^#include (\S+);/mg) { push @todo, "$dir$1" unless $done{"$dir$1"}++; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: changing inside a file
by amoura (Initiate) on Aug 26, 2002 at 19:22 UTC |