in reply to Deleting text from a file using regex

You need the "g" modifier to replace all instances.

perl -pe"s/-\w{2,}/ /g" infile > outfile

Or in-place:

perl -i.bak -pe"s/-\w{2,}/ /g" file

Or in code

while (<$fh_in>) { s/-\w{2,}/ /g; print $fh_out $_; }

Replies are listed 'Best First'.
Re^2: Deleting text from a file using regex
by b_vulnerability (Novice) on Nov 10, 2008 at 10:48 UTC
    I forgot the g modifier, apparently, because now my regex works just fine! Thanks, really!