open (DATA,"$input_file") || eval { print "Can't open file $input_file: $@"; exit; };
BTW: Are you aware that this is a very strange error handler for an open statement? As best I can figure, it uses an eval expression to print the value of a previous (Update: No! See below.) eval error ($@ - see perlvar; in particular, Error Variables) as the file open error message. Why not just use a 'standard'
open my $fh, '<', $input_file or die "opening '$input_file': $!";
(see $! in perlvar and Error Variables).
Update: A simple experiment, which I didn't have time to do before, shows that $@ is emptied upon entry to an eval block:
>perl -wMstrict -le "eval { die 'zot!' }; print qq{after first eval: '$@'}; ;; eval { print qq{in second eval: '$@'} }; " after first eval: 'zot! at -e line 1. ' in second eval: ''
In any event, $@ is not the proper error variable to print after an I/O error.
In reply to Re: Parsing a long string [OT]: strange open
by AnomalousMonk
in thread Parsing a long string
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |