> I have a file with some settings, and I want to change some
> of them. But when I write the file, I lose everything after a
> certain point.
>
> Can someone point out my moronic mistake?
> Everything after "ROOT =" is lost but it changes "ROOT =" to
> the correct value.
>
> # perl here
> $out = "";
> open(TMPL, "$tree_path/$file");
> {
> local $/ = "";
> $out = <TMPL>;
> }
> close TMPL;
>
> open(NEW, ">$tree_path/$client_uc/$patch/$file");
> $out =~ s/^ROOT\s*=\s*.*?$/SUMMITROOT=$tree\/$extra/m;
> # replace
> root line
> $out =~ s/^#(un)?def(ine)?\s+REFROOTDIR.*?$/#define REFROOTDIR
> $old$extra/m; #replace refrootdir line
> print NEW $out;
> close NEW;
> print "Edited $tree_path/$file\n";
>
> __END__
When you do a multi-line match, I'm pretty sure $ matches the end of the
entire string. Try matching \n instead of $ - I think that should do it.
-dave
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]