On Fri, 2 Apr 2004 15:19:13 -0800 (PST) LoneWolf <[EMAIL PROTECTED]> wrote:
> I have a file that I need to replace the *| and || with just | and can > not seem to get it to go. It either puts in an | every space, or it > puts in multiples of them, how do I fix this? > > here's what I have: The '|' character is a special character in a Perl RE. Try escaping it. Also why are you using the 'm' flag in the substitute operator? I do not think you need it. > sub cleanup{ > > use strict; > > my $file = "/home/web/sales/info/test/custs1"; > my $newfile = "/home/web/sales/info/test/fixed.txt"; > my $line; > > open (OLDFILE, "< $file"); > open (NEWFILE, "> $newfile"); > while ($line = <OLDFILE>) { > $line =~ s/||/|/mg; > $line =~ s/\*|/|/mg; > print NEWFILE "$line\n"; > } > close OLDFILE; > close NEWFILE; > > print "$newfile has now been created\n"; > } > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > -- Smoot Carl-Mitchell Systems/Network Architect email: [EMAIL PROTECTED] cell: +1 602 421 9005 home: +1 480 922 7313 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>