Perl-Sensitive Sunglasses | |
PerlMonks |
Variable assignment after logical ORby rq-2102 (Acolyte) |
on Oct 02, 2007 at 18:40 UTC ( [id://642199]=perlquestion: print w/replies, xml ) | Need Help?? |
rq-2102 has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks, I've been having a bit of trouble with getting perl to act reliably following a logical OR statement in code. I want to perform multiple operations in case of a failure when opening a file for write, and so my choices would seem to be to call a subroutine or to set a flag indicating a failure. For example: open FILE, ">test.txt" || $failed_flag = 1; The above example will not compile, I've also tried with using a &subroutine instead of a direct assignment with no luck. It compiles, but the subroutine seems to never actually run...
--------- Brian
Back to
Seekers of Perl Wisdom
|
|