A couple of notes.
In addition to checking the table in perlop, you can check precedence using the -p option of B::Deparse.
>perl -MO=Deparse,-p -e"open FILE, $file || die" open(FILE, ($file || die)); -e syntax OK >perl -MO=Deparse,-p -e"open FILE, $file or die" (open(FILE, $file) or die); -e syntax OK
General rule: Only use || when you're saving the value of the OR.
You mentioned in the ChatterBox that you thought your file handles were being closed automatically when the subroutine exits. In your case, they weren't before adding explicit calls close.
File handles are automatically closed when they go out of scope and there are no more references to them. Since you are using a global variable (*SAVE) as your file handle, and since you don't localize it, it never goes out of scope.
Fix:
open(local *FH, '<', $file) or die("Unable to open file \"$file\": $!\n");
open(my $fh, '<', $file) or die("Unable to open file \"$file\": $!\n");
In reply to Re: Inappropriate ioctl for device
by ikegami
in thread Inappropriate ioctl for device
by downer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |