Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

RE: RE: RE: mybooks.pl (or or )

by tye (Sage)
on Aug 09, 2000 at 08:29 UTC ( #26956=note: print w/replies, xml ) Need Help??


in reply to RE: RE: mybooks.pl (or or )
in thread mybooks.pl

And in the case we are discussing here, || is very much wrong. Consider the first example of || die in the posted code:

mkdir "$dir", 0777 || die "Could not mkdir \"$dir\": $!\n";

Here is a demonstration of why this is wrong:

my $dir= "source"; # A directory that I know exists. warn "Using or...\n"; mkdir "$dir", 0777 or die "Could not mkdir \"$dir\": $!\n"; warn "Using ||...\n"; mkdir "$dir", 0777 || die "Could not mkdir \"$dir\": $!\n"; warn "Done.\n";

This produces the following output:

E:\etm\Work>perl -w mkdir.pl Using or... Could not mkdir "source": File exists Using ||... Done.

Note that -w was silent as well, so I'm not sure when it will warn me of a precedence problem (I'm using Perl 5.6.0).

        - tye (but my friends call me "Tye")

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://26956]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2022-05-27 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (94 votes). Check out past polls.

    Notices?