# trytest.pl - a simple test of new perl 5.38 try syntax: # Put TestTry.pm in same dir as trytest.pl and run with: # perl -I . trytest.pl # Note: use v5.38 implies use strict and warnings use v5.38; # use feature 'try'; # throws 'try/catch is experimental' warnings (update: works with perl v5.40.0 if you are not using finally blocks) use experimental 'try'; use TestTry; sub do_one { my $number = shift; try { TestTry::life($number); } catch ($e) { chomp $e; print "trytest: caught '$e'\n"; } finally { print "trytest: in finally block\n"; } } print "trytest: start\n"; do_one("invalid"); do_one(13); do_one(42); print "trytest: end\n";