vcherubini
Programmer
I have a question about the [tt]eval{}[/tt] function.
How would I get Perl to evaluate a piece of code that checks to see whether a file exists, and depending on whether it does or not, something happens.
Say for example, I have this code:
[tt]
eval {
open(FILE, "file.txt"
;
@data = <FILE>;
close(FILE);
};
if ($@) { print "the file does not exist\n"; }
else { print "the file does exist\n"; }
[/tt]
Whenever I try that, I always get the same message, whether or not the file does or does not exist.
If anyone can help, THANKS in advance.
-Vic [sig]<p>vic cherubini<br><a href=mailto:malice365@hotmail.com>malice365@hotmail.com</a><br><a href= software</a><br>====<br>
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director<br>
Wants to Know: Java, Cold Fusion, Tcl/TK<br>
====[/sig]
How would I get Perl to evaluate a piece of code that checks to see whether a file exists, and depending on whether it does or not, something happens.
Say for example, I have this code:
[tt]
eval {
open(FILE, "file.txt"
@data = <FILE>;
close(FILE);
};
if ($@) { print "the file does not exist\n"; }
else { print "the file does exist\n"; }
[/tt]
Whenever I try that, I always get the same message, whether or not the file does or does not exist.
If anyone can help, THANKS in advance.
-Vic [sig]<p>vic cherubini<br><a href=mailto:malice365@hotmail.com>malice365@hotmail.com</a><br><a href= software</a><br>====<br>
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director<br>
Wants to Know: Java, Cold Fusion, Tcl/TK<br>
====[/sig]