in reply to Inserting Text into Files within a Directory
Maybe your open is failing because you're not looking in $dir? Try this:
open(OLD,"<$dir/$file") or die "can't open $dir/$file: $!";
As for your substitutions, here's one way to do it (note: untested code):
my $data = do {local $/; <OLD>}; # slurp the whole file in to $data my @replace_list = ('','Notes:','Director:','Actors:'); while ($data =~ s/(?<=$search)/shift @replace_list/egs) {};
BTW, I can understand doing it the quick-and-dirty way with s///, but if this is more than just a one-off thing, you might consider doing it with XML::Parser.
-b
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Inserting Text into Files within a Directory
by LF (Initiate) on Aug 24, 2004 at 15:03 UTC | |
by bgreenlee (Friar) on Aug 24, 2004 at 15:15 UTC | |
by bgreenlee (Friar) on Aug 24, 2004 at 15:34 UTC | |
by LF (Initiate) on Aug 24, 2004 at 16:04 UTC | |
by revdiablo (Prior) on Aug 24, 2004 at 17:05 UTC |