use strict;
use warnings;
use Spreadsheet::ParseExcel;
my $file = shift;
my $excel;
eval {
local $SIG{ALRM} = sub { die "timeout\n" };
alarm(5);
$excel = Spreadsheet::ParseExcel::Workbook->Parse($file);
die "Can't parse $file\n" unless defined $excel;
alarm(0);
};
die $@ if $@;
# contiune with $excel object
####
open DUMP, ">filename" or die "Can't open: $!\n";
####
if ($@) { # something bad occures
if ($@ =~ /TIME OUT/) {
# do something regarding timeout
} else {
# do something with other reason,
# such as failure on open
}
# stop here
}
# continue here