File Coverage

blib/lib/Acme/Loopy.pm
Criterion Covered Total %
statement 20 21 95.2
branch n/a
condition n/a
subroutine 8 9 88.8
pod n/a
total 28 30 93.3


line stmt bran cond sub pod time code
1 1     1   33701 use 5.012;
  1         4  
  1         40  
2 1     1   5 use strict;
  1         3  
  1         35  
3 1     1   6 use warnings;
  1         6  
  1         29  
4 1     1   1160 use Keyword::Simple ();
  1         19805  
  1         217  
5              
6             {
7             package Acme::Loopy;
8            
9             our $AUTHORITY = 'cpan:TOBYINK';
10             our $VERSION = '0.003';
11            
12             sub import
13             {
14             Keyword::Simple::define loop => sub {
15 5     5   75 my ($ref) = @_;
16 5         45 my $rand = 99_999 + int rand 900_000;
17 5         406 substr($$ref, 0, 0) =
18             q{ local ${^_LOOP_OLD} = ${^LOOP}; } .
19             q{ local ${^_LOOP_CURRENT} = -1; } .
20             q{ while ( ${^LOOP} = ++${^_LOOP_CURRENT}, my $__guard_}.$rand.q{ = Acme::Loopy::Guard->new(${^_LOOP_OLD}, \${^LOOP}) )};
21 1     1   16 };
22             }
23            
24             sub unimport
25             {
26 0     0   0 Keyword::Simple::undefine loop => ();
27             }
28             }
29              
30             {
31             package Acme::Loopy::Guard;
32              
33             our $AUTHORITY = 'cpan:TOBYINK';
34             our $VERSION = '0.003';
35            
36             sub new
37             {
38 90     90   192 my $class = shift;
39 90         231 bless \@_, $class;
40             }
41            
42             sub DESTROY
43             {
44 90     90   838 ${$_[0][1]} = $_[0][0];
  90         278  
45             }
46             }
47              
48             1;
49              
50             __END__