On Nov 1, 10:00 am, [EMAIL PROTECTED] (Beginner) wrote:
> On 1 Nov 2007 at 19:20, Kaushal Shriyan wrote:
>
>
>
>
>
> > Hi
>
> > I am using FileHandle, Below is my code
> > ########################################
>
> > #!/usr/bin/perl
>
> > use warnings;
> > use strict;
>
> > open(LOGFILE, "messages")
> >         || warn "Could not open messages";
> > open(DATA, ">/tmp/data") || die "Could not create /tmp/data\n."
>
> > while (<LOGFILE>) {
> >         print "$_\n" if /MARK/;
> > }
> > #######################################
>
> > I am getting syntax error
>
> > I know i am doing wrong, please let me know whats causing the issue.
>
> Did the error give a line number? I think it's the lack of brackets
> on the if clause.
>
>  while (<LOGFILE>) {
>          print "$_\n" if ( /MARK/ );
>  }
>
> Hope I'm not too far off.

Please don't guess.  If you don't know the answer, either research and
find the right answer, or just let other people answer.  Giving wrong
information is far worse than giving no information.

First, ( and ) are parentheses, not brackets.  Second, the postfix
notation of if/unless/while/until/foreach do not require parentheses.

Paul Lalli


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to