----- Original Message ----- From: "Adrian Farrell" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, June 11, 2002 5:25 PM Subject: invisible syntax error
> hi, > > I simply wished to strip out all the ">" from a text file. below is the > script and the error that is reported. I cannot see anything wrong, it's > such a simple piece of code! can any one help, are my eyes deceiving me? > > thanks, > Adrian > > #!/usr/bin/perl -w > > open(INPUT, "letter.txt") || die "can't open file: $!"; > open(OUTPUT, ">newletter.txt"); > > while (<INPUT>){ > if(S/\>//){ > print OUTFILE; > } > } > > Try this : while (<INPUT>) { print OUTFILE if ( s/>//g ) } Then, plus... 1. "s///", not "S///", 2. use s///g, otherwise, it will subsititute only 1 match at max for a line. 3. you seems forgot to close INPUT 4. OUTFILE is not the handle OUTPUT you open for write > C:\>perl clean.pl > syntax error at clean.pl line 7, near "\>" > syntax error at clean.pl line 10, near "}" > Execution of clean.pl aborted due to compilation errors. > > _________________________________________________________________ > Chat with friends online, try MSN Messenger: http://messenger.msn.com > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]