#!/usr/bin/perl -w use strict; my $infile = "/dir/infilename"; my $outfile = "/dir/outfilename"; open (IN, "$infile") or die "Error opening $infile: $!\n"; open (OUT, ">$outfile") or die "Error opening $outfile: $!\n"; while () { s/wahwah//g; # unwanted text s/blahblah//g; # more unwanted text s/yadayada//g; # still more unwanted text s/^\s+//g; # blank lines print OUT $_ or die "Error writing to $outfile: $!\n"; } close (IN) or die "Error closing $infile: $!\n"; close (OUT) or die "Error closing $outfile: $!\n"; # END