http://www.perlmonks.org?node_id=642480


in reply to Variable assignment after logical OR

Others have told you what's wrong with your code, but I'd like to mention that there are other options besides a flag value and a subroutine. In particular, I would suggest something like
unless(open FILE, ">test.txt"){ #error handling code goes here }