Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

division sign, even in comment results in syntax error

by dcy (Initiate)
on Jul 31, 2009 at 08:26 UTC ( #784840=perlquestion: print w/replies, xml ) Need Help??

dcy has asked for the wisdom of the Perl Monks concerning the following question:

Dear All,

A weird one: I have a lengthy subroutine (that I cannot post here) that runs fine on ubuntu 9.04 (perl 5.10), but does not compile on ubuntu 8.04 (perl 5.8.8) that I have to use for production.

If at line 434 I add / sign, be it my $a=4/3; or in comment ( # blabla/bla), I get

syntax error at sub.pm line 523, near "){"
syntax error at sub.pm line 543, near "){"
syntax error at sub.pm line 552, near "){"
syntax error at sub,pm line 561, near "else"

which correspond to switch, case, else statements.

I could use sign($a)*exp(-log(abs($a))) instead of /$a, but this does not really solve my problem.

Does it ring a bell to anyone?

Thanks

Damien
  • Comment on division sign, even in comment results in syntax error

Replies are listed 'Best First'.
Re: division sign, even in comment results in syntax error
by salva (Abbot) on Jul 31, 2009 at 08:41 UTC
    ...but does not compile on ubuntu 8.04 (perl 5.8.8)
    ...which correspond to switch, case, else statements

    Are you using Switch? don't do it!

    Switch is not reliable, it is a source filter that parses perl code and modifies it on the fly and sometimes does it wrongly.

      You were right, I have replaced my switch case statements with ifs elsifs and now everything works fine.

      Thanks really a lot.

      Damien
Re: division sign, even in comment results in syntax error
by mzedeler (Pilgrim) on Jul 31, 2009 at 08:36 UTC

    Here is an approach to identify the problem.

    Start cutting out half of the source code, making sure that it is still syntactically correct (according to your opinion) and see if the error still persists. If it doesn't, backtrack and cut away the other half. Keep reducing your code like this until you have less than 10 lines that exhibits the error. The solution should then be apparent.

    If the solution is not apparent, post the 10 lines here.

Re: division sign, even in comment results in syntax error
by moritz (Cardinal) on Jul 31, 2009 at 08:49 UTC
    Maybe you are using the // (defined-or) operator somewhere?

    It was introduced in perl-5.10, so 5.8 might give syntax errors.

Re: division sign, even in comment results in syntax error
by xyzzy (Pilgrim) on Jul 31, 2009 at 16:07 UTC
    you may also have an open regex somewheres (or something that is being read as a regex). finding unpaired delimiters is one of the most annoying things ever since it is usually miles away from the line where perl actually catches the problem


    Everything is true." "Even false things?" "Even false things are true" "How can that be?" "I dunno man, I didn't do it."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://784840]
Approved by salva
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2020-06-05 01:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (35 votes). Check out past polls.

    Notices?