I am using PDF::Reuse to write a new pdf:
use PDF::Reuse;
prFile( $copyPdf );
prDoc( $old ) ;
prEnd();
works great but if there's an error, the entire 开发者_如何学Cscript dies...how can I instead just "warn" if Reuse encounters a problem?
Wrap it in a block eval
:
use PDF::Reuse;
eval {
prFile( $copyPdf );
prDoc( $old ) ;
prEnd();
1;
} or warn $@;
Or better yet, use Try::Tiny
(it does the same thing but in a safer way):
use Try::Tiny;
use PDF::Reuse;
try {
prFile( $copyPdf );
prDoc( $old ) ;
prEnd();
} catch {
warn $_;
};
精彩评论