Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: open failure code

by Revelation (Deacon)
on Nov 26, 2003 at 23:17 UTC ( #310409=note: print w/replies, xml ) Need Help??


in reply to open failure code

It's all about operator precedence. For more information about precedence theory checkout perlop.
Regarding your specific problem:
The line  open ($fh,$log) || $down = 'moo'
is evaluated as (open ($fh,$log) || $down) = 'moo';
Obviously, open isn't an lvalue function; you can't assign it a value.
$log = "moooojlfdkafj.txt"; $down="false"; open (FH, $log) || ( $down = "true" ); print $down;
or
$log = "moooojlfdkafj.txt"; $down="false"; open (FH, $log) or $down = "true"; print $down;
work.

Gyan Kapur

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://310409]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2018-07-20 03:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (424 votes). Check out past polls.

    Notices?