Welcome from the shell scripting world. I know that $! has been your trusty friend for a long time, but Perl relies on return values. The $! serves to communicate error information about failures but it itself does not return true or false regarding successes or failures of specific system calls. If you want to check for success or failure, you should really capture the return value of the open. Although, in Perl, we rarely do that, instead you'd feed it right into an if-then-else statement:
open TT1, "<test.out" ? do { print "1. [OK]\n"; @x = <TT1>; close TT1; } : print "[ERROR]\n";
Notice how we get the desired behavior. You can do the same for the other sections as well.
HTH
In reply to Re: unable to open existing file after trying to open a non-existing one
by pzbagel
in thread unable to open existing file after trying to open a non-existing one
by monk_of_gaia
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |