Checks whether an unopened file actually exists.
#!/usr/local/bin/perl
unless (open(MYFILE, "file1")) {
if (-e "file1") {
die ("File file1 exists, but cannot be opened.\n");
} else {
die ("File file1 does not exist.\n");
}
}
$line = <MYFILE>;
while ($line ne "") {
chop ($line);
print ("\U$line\E\n");
$line = <MYFILE>;
}
Related examples in the same category