Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: Default Hash Key

by roboticus (Chancellor)
on May 02, 2008 at 10:42 UTC ( [id://684131]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Default Hash Key
in thread Default Hash Key

tford:

perldoc perlop yields:

C-style Logical Or

Binary "||" performs a short-circuit logical OR operation. That is, if the left operand is true, the right operand is not even evaluated. Scalar or list context propagates down to the right operand if it is evaluated.

The "||" and "&&" operators return the last value evaluated (unlike C's "||" and "&&", which return 0 or 1). Thus, a reasonably portable way to find out the home directory might be:

$home = $ENV{'HOME'} || $ENV{'LOGDIR'} || (getpwuid($<))[7] || die "You're homeless!\n";
...roboticus

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2025-01-18 11:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (56 votes). Check out past polls.