use strict; use warnings; my ($wholefile,$line); my $outfilename='orderdata.out'; {open INFILE, '<', "orderform.rtf"; local $/; $wholefile=; close(INFILE); $wholefile =~ s/^\s*{.*\n//g; # remove lines starting with braces $wholefile =~ s/\\[\w-]+\b//g; # remove RTF commands $wholefile =~ s/(\n)\s+(\S+)/$1$2/g; # remove extra spaces $wholefile =~ s/([^\\\n]+)\\(\n)/$1$2/g; # get rid of \ at the ends of lines $wholefile =~ s/\\\n//g; # get rid of lines with a \ only open OUTFILE,'>',$outfilename or die "Can't open $outfilename!\n"; print OUTFILE $wholefile; close(OUTFILE); }