| 1 | package App::supertouch; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use 5.008001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Path::Tiny qw( path ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | # ABSTRACT: Touch with directories | ||||||||||||||||||||||||||||
| 9 | 1 | our $VERSION = '0.02'; # VERSION | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | sub main | ||||||||||||||||||||||||||||
| 13 | 3 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
main: called CC=16 SCAR=37.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 14 | 3 | my(undef, @args) = @_; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 3 | my $verbose = 0; | |||||||||||||||||||||||||||
| 17 | 3 | my $options = 1; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 3 | foreach my $arg (@args) | |||||||||||||||||||||||||||
| 20 | { | ||||||||||||||||||||||||||||
| 21 | 3 | ▶ | if($options && $arg =~ /^-/) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$options and $arg =~ /^-/
MC/DC0%0/2
$options and $arg =~ /^-/
$options
$arg =~ /^-/
Truth table33%1/3
A and B
A= $optionsB= $arg =~ /^-/
| |||||||||||||||||||||||||||||
| 22 | { | ||||||||||||||||||||||||||||
| 23 | 0 | ▶ | if($arg eq '--') | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 24 | { | ||||||||||||||||||||||||||||
| 25 | 0 | $options = 0; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | elsif($arg eq '-v') | ||||||||||||||||||||||||||||
| 28 | { | ||||||||||||||||||||||||||||
| 29 | 0 | $verbose = 1; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | 0 | next; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | 3 | ▶ | if($arg eq '') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | { | ||||||||||||||||||||||||||||
| 35 | 0 | print STDERR "'' (empty) is not a legal filename"; | |||||||||||||||||||||||||||
| 36 | 0 | return 2; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | 3 | ▶ | if($arg =~ s{[\\/]$}{}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | { | ||||||||||||||||||||||||||||
| 40 | 1 | my $dir = path($arg); | |||||||||||||||||||||||||||
| 41 | 1 | ▶ | if($dir->is_file) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | { | ||||||||||||||||||||||||||||
| 43 | 0 | print STDERR "$dir is a file"; | |||||||||||||||||||||||||||
| 44 | 0 | return 2; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | 1 | ▶ | unless(-d $dir) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | { | ||||||||||||||||||||||||||||
| 48 | 0 | ▶ | print "DIR @{[ $dir ]}\n" if $verbose; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 1 | $dir->mkpath; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | else | ||||||||||||||||||||||||||||
| 53 | { | ||||||||||||||||||||||||||||
| 54 | 2 | my $file = path($arg); | |||||||||||||||||||||||||||
| 55 | 2 | ▶ | if($file->is_dir) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | { | ||||||||||||||||||||||||||||
| 57 | 0 | print STDERR "$file is a directory"; | |||||||||||||||||||||||||||
| 58 | 0 | return 2; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | 2 | ▶ | unless(-d $file->parent) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | { | ||||||||||||||||||||||||||||
| 62 | 0 | ▶ | print "DIR @{[ $file->parent ]}\n" if $verbose; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 2 | $file->parent->mkpath; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | 2 | ▶ | unless(-f $file) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | { | ||||||||||||||||||||||||||||
| 67 | 0 | ▶ | print "FILE @{[ $file ]}\n" if $verbose; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 2 | $file->touch; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 3 | return 0; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 1 | 1; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | __END__ | ||||||||||||||||||||||||||||