in reply to Re: Error in Camel Book Ver2?
in thread Error in Camel Book Ver2?

if I make a script that says:

$pi ||= 3 print $pi;

I'll get back something like

syntax error at or.pl line 1, near "|| ="

So the way its written won't work

I wonder if this will be different if your testing a hash, since you use exists() instead of defined();

Replies are listed 'Best First'.
Re: Re: Re: Error in Camel Book Ver2?
by merlyn (Sage) on Dec 21, 2000 at 11:51 UTC
    syntax error at or.pl line 1, near "|| ="
    That's a Perl4 (or earlier) error message. Please upgrade to a version of Perl that was released sometime after the Spice Girls hit the pop charts.

    -- Randal L. Schwartz, Perl hacker

      merlyn, I've gotta say this was a great laugh for this morning =] Maybe future versions of perl should be named after the current music sensation of the time of release. =]

      [marius@marius.org ~]$ perl -v This is perl, the N'Sync version built for i386-freebsd Copyright 1987-1999, Larry Wall ...

      -marius
      Perl 4 didn't support overloading = with ||?

      If so, did it support the = and || operators?

      And if so, couldn't we use this: $value = $value || 'DEFAULT'; to accomplish the same thing?

      (Not that I don't support the idea of upgrading Perl to a recent version, but the Spice Girls are pretty old news themselves. *grin*)
Re: Re: Re: Error in Camel Book Ver2?
by myocom (Deacon) on Dec 21, 2000 at 11:56 UTC

    The code that you provide there is not the code giving you that error message. The error message you list indicates that you have an extraneous space in ||=. ||= should not have any spaces.

    The code you provided will give you an entirely different error, namely syntax error at - line 2, near "print" since you didn't have a semicolon at the end of the first line.

      ahh,

      huh,

      hmm,

      that's a weird place for spaces to make a difference, since,

      $pi = $foo || 67;

      will work, oh well, thanks everyone,

      thinks for a minute, ....

      Ohhh i see, ||= is an assignment operator, sweet cake, thanks everyone

       

      -justin simoni
      !skazat!