$SIG{__DIE__}=sub( my $d=shift; if($d eq 'error to really die on'){ print $d; exit; }elsif($d eq 'some other die to handle specially'){ # do some special code to recover from this die } #just return to code on other dies ); $_=PDF::Core::PDFGetline ($fd,\$offset); die "Can't read cross-reference section, according to trailer\n" if ! /xref\r?\n?/ ; #resturn to default DIE handler $sig{__DIE__}='DEFAULT';