Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

zatoichi (4897)

zatoichi
  (email not shown publicly)

Perl Initiate

Journal of zatoichi (4897)

Tuesday February 24, 2004
06:05 PM

Learning Perl v3: Chapter 2

[ #17610 ]

This is about scalars and strings.

I did all the excercises and got them right.

I have never been sure when writing code before now (like in a 'die' statement) whether to use || or the OR operator. I am sure it will become apparent or at least more so as I go through the excercises.

I am typing in and testing all the examples as well as doing all the excercises. Learn by doing is the best way.

note: this actually catches me up as I am in the 3rd chapter.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • The distinction between the two is very slim: || has a higher precedence, while or has a very low precedence. So choose just based on what kind of precedence you want. For example:

    print "do" || "die";

    evaluates the whole RHS as an expression for print, while

    print "do" or die;

    evaluates print "do" and will die() only when print fails for example when printing to a closed filehandle, of to a full disk.

    I just hope I seem to make sense.

  • I have never been sure when writing code before now (like in a 'die' statement) whether to use || or the OR operator.

    Of those two, always the first, as the OR operator no longer exists (it was made lower case).