in reply to Remove string from file
Thanks for finding a solution guys and gals. Just saved me the headache of having to remove the word "remove" appended on the end of each line in a document with 300 lines.
--#!perl print "What is the name of the file you want to remove a word ar phras +e from? \nPlease include the extension. \n"; chomp(my $rem_name = <STDIN>); print "Please enter a word ar phrase you want to remove: \n"; chomp(my $replacestring = <STDIN>); open(my $infile,"<","$rem_name") or die $!; open (my $outfile,">","outputfile.txt") or die $!; while (<$infile>) { $_=~s/$replacestring//g; print $outfile $_; } close $infile; close $outfile;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Remove string from file
by AnomalousMonk (Archbishop) on Jan 01, 2015 at 06:40 UTC |