example.pl untested

filter: Statementstmt 0.0% 0 / 26 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 33 CC 1 SCAR 6.9
CC
1
Cov
0%
bar
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/perl
2  
3 use strict;
4 use warnings;
5  
6 use Try::Tiny;
7 use Try::Tiny::Warnings;
8  
9 {
10 package Foo;
11  
12 use warnings;
13  
14 sub bar { 1 + shift }
15 }
16  
17 Foo::bar(); # warn
18  
19 try_fatal_warnings {
20 Foo::bar();
21 }
22 catch {
23 print "tsk, got $_";
24 };
25  
26 try_warnings {
27 Foo::bar();
28 warn "some more";
29 }
30 catch {
31 print "won't be printed\n";
32 }
33 catch_warnings {
34 print "we warned with: $_" for @_;
35 };
36  
37  
38  
39  
40