Re: [htmltmpl] How to exit gracefully when template is not found?
Brought to you by:
samtregar
From: Sam T. <sa...@tr...> - 2004-07-10 15:45:39
|
On Sat, 10 Jul 2004, Nishikant Kapoor wrote: > I would like to catch this error and do a graceful exit by displaying > "'my.tmpl' not found!" message back to user. Easily done. Just use eval{} to catch the die() and check $@ to examine any error: my $template; eval { $template = HTML::Template->new(filename => 'my.tmpl'); }; if ($@ and $@ =~ /file not found/) { print "my.tmpl not found!"; exit; # or return as appropriate } elsif ($@) { die $@; } -sam |