Well, you don’t need to use die to get information from $!:
#! perl use Modern::Perl; for my $file ('465_SoPW.pl', 'Non-Existent.txt') { if (my @stats = stat $file) { say "File '$file' last modified: ", $stats[9]; } else { say "stat failed for file '$file': $!"; } }
Output (on my machine):
0:17 >perl 466_SoPW.pl File '465_SoPW.pl' last modified: 1357188675 stat failed for file 'Non-Existent.txt': No such file or directory 0:17 >
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re^3: stat : error handling
by Athanasius
in thread stat : error handling
by gepebril69
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |