> hello, > what is the easiest way to replace text in a file? say i > have file blah.txt > and i want to replace some regular expression found in that file with > something. also, i want to do this from within the perl > program, not by > invoking perl with the -e option. #!/usr/bin/perl -w
use strict; print `perl -pi -e "s/\b\d+\b/123/ if /^YOURNUMBER/" fix.txt file2.txt joe.html`; Sorry, I couldn't resist ;p Although that'd still do it from inside your script Ok depending on the file size ( IE if it's not huge ) use File::Slurp; my $file = read_file($file); # or @file and do a for() on that array $file =~ s/Hello/Goodbye/gl write_file($file); Or use open() instead of the File::Slurp methods. HTH DMuey > > thanks, > -- christopher > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]