File Coverage

blib/lib/Acme/Presume.pm
Criterion Covered Total %
statement 21 21 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 29 29 100.0


line stmt bran cond sub pod time code
1             package Acme::Presume;
2 2     2   52570 use strict;
  2         5  
  2         78  
3 2     2   10 use warnings;
  2         4  
  2         646  
4 2     2   12 use Exporter;
  2         7  
  2         225  
5              
6             our (@ISA, @EXPORT_OK);
7             our $VERSION = 1.00;
8              
9             BEGIN {
10 2     2   11 require Exporter;
11 2         30 @ISA = qw(Exporter);
12 2         116 @EXPORT_OK = qw(presume);
13             }
14              
15             =head1 NAME
16              
17             Acme::Presume - Presume that the block of code should never see the light of day.
18              
19             =head1 DESCRIPTION
20              
21             Presume will allow one to execute a block of code, without the burden of strict
22             variable checking, seeing warnings, or worrying about failure. Code will execute
23             perfectly, within presume, every time.
24              
25             There isn't one good reason this module should exist. Yet, here we are.
26              
27             pre-sume (v)
28              
29             1. suppose that something is the case on the basis of probability.
30              
31             2. be audacious enough to do something.
32              
33             =head1 USAGE
34              
35             use Acme::Presume qw(presume);
36              
37             presume sub {
38             die 'Oh no!';
39             };
40              
41             =head1 PUBLIC METHODS
42              
43             =over 4
44              
45             =item presume( BLOCK )
46              
47             Execute this block under eval, without strict, and without warnings. Will return
48             the end value of the block, but swallow any exceptions, warnings, or failure.
49              
50             =cut
51              
52             sub presume {
53 4     4 1 715 my ($block) = @_;
54              
55 4         7 return eval {
56 2     2   10 no warnings;
  2         3  
  2         77  
57 2     2   9 no strict;
  2         3  
  2         113  
58 4         10 $block->();
59             }
60             }
61              
62             =back
63              
64             =head1 LICENSE
65              
66             Copyright 2014, Nicholas Melnick. This library is free software; you may
67             redistribute it and/or modify it under the same terms as Perl itself.
68              
69             =cut
70              
71             1;