Solved

simple syntax question

Posted on 2004-08-25
3
146 Views
Last Modified: 2010-03-05
Hi,

Is there anything wrong with the following in Perl:

if(0){;}
elsif(($char eq "'") or ($char == '"')){;}

Perl does not seem to like '"', but I think it is valid.
0
Comment
Question by:rmundkowsky
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 18

Accepted Solution

by:
kandura earned 50 total points
ID: 11898032
You're right:

    c:\> perl -c
    if(0){;}
    elsif(($char eq "'") or ($char == '"')){;}
   
    - syntax OK

Maybe the error occurs further up your script?
0
 

Author Comment

by:rmundkowsky
ID: 11898049
Ah, yep you got it.  Thanks
0
 
LVL 84

Expert Comment

by:ozo
ID: 11919346
perl -Mdiagnostics -w
if(0){;}
elsif(($char eq "'") or ($char == '"')){;}

Use of uninitialized value in string eq at - line 1 (#1)
    (W uninitialized) An undefined value was used as if it were already
    defined.  It was interpreted as a "" or a 0, but maybe it was a mistake.
    To suppress this warning assign a defined value to your variables.
   
    To help you figure out what was undefined, perl tells you what operation
    you used the undefined value in.  Note, however, that perl optimizes your
    program and the operation displayed in the warning may not necessarily
    appear literally in your program.  For example, "that $foo" is
    usually optimized into "that " . $foo, and the warning will refer to
    the concatenation (.) operator, even though there is no . in your
    program.
   
Argument """ isn't numeric in numeric eq (==) at - line 1 (#2)
    (W numeric) The indicated string was fed as an argument to an operator
    that expected a numeric value instead.  If you're fortunate the message
    will identify which operator was so unfortunate.
   
Use of uninitialized value in numeric eq (==) at - line 1 (#1)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question