blib/lib/Acme/Scripticide.pm untested

filter: Statementstmt 0.0% 0 / 33 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 82 CC 6 SCAR 23.5
CC
6
Cov
0%
import
20.0
good_bye_cruel_world
12.0
BEGIN
2.0
CRAP 10.5
1 package Acme::Scripticide;
2  
3 use strict;
4 use warnings;
5 use version;our $VERSION = qv('0.0.4');
6  
7 use File::Spec;
8 use Carp;
9  
10 sub import {
11 $_[1]='' if !defined $_[1];
12 *main::good_bye_cruel_world = *{Acme::Scripticide::good_bye_cruel_world} if $_[1] eq 'good_bye_cruel_world';
13 good_bye_cruel_world($_[1], join(' ', @_[ 2 .. $#_ ])) if $_[1] ne 'good_bye_cruel_world';
14 }
15  
16 sub good_bye_cruel_world {
17 if(defined $_[0] && $_[0] =~ m/^\.\w+$/) {
18 my $new = File::Spec->rel2abs($0);
19 $new =~ s/\.\w+$//;
20 open my $heart, '>', "$new$_[0]" or carp "'$new$_[0]' I have too much to live for, open: $!";
21 print $heart $_[1];
22 close $heart;
23 unlink File::Spec->rel2abs($0) or carp "'$0' I have too much to live for, unlink: $!";
24 }
25 elsif(defined $_[0] && $_[0]) {
26 my $note = join(' ', @_);
27 open my $heart, '>', File::Spec->rel2abs($0) or carp "'$0' I have too much to live for, open: $!";
28 print $heart $note;
29 close $heart;
30 }
31 else {
32 unlink File::Spec->rel2abs($0) or carp "'$0' I have too much to live for, unlink: $!";
33 }
34 }
35  
36 1;
37  
38 __END__