| 1 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | package File::PlainPath; | ||||||||||
| 4 | |||||||||||
| 5 | # ABSTRACT: Construct portable filesystem paths in a simple way | ||||||||||
| 6 | |||||||||||
| 7 | 4 | our $VERSION = '0.030'; # VERSION | |||||||||
| 8 | |||||||||||
| 9 | 4 | ▶ | use File::Spec; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | |||||||||||
| 12 | 4 | require Exporter; | |||||||||
| 13 | 4 | our @ISA = qw(Exporter); | |||||||||
| 14 | 4 | our @EXPORT_OK = qw(path to_path); | |||||||||
| 15 | |||||||||||
| 16 | sub import | ||||||||||
| 17 | 7 | ▶ | { | ||||||||
|
Subroutine
import: called CC=4 SCAR=13.9
| |||||||||||
| 18 | 7 | my $class = shift; | |||||||||
| 19 | 7 | my %opts = (); | |||||||||
| 20 | 7 | my @export = (); | |||||||||
| 21 | 7 | ▶ | while (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 11 | my $arg = shift; | |||||||||
| 23 | 11 | ▶ | if ($arg =~ m{^ [-] (.+) $}x) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | { | ||||||||||
| 25 | 6 | $opts{$1} = shift; | |||||||||
| 26 | 6 | next; | |||||||||
| 27 | } | ||||||||||
| 28 | 5 | push @export, $arg; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 7 | ▶ | if (exists $opts{'separator'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 6 | $^H{+__PACKAGE__} = $opts{'separator'}; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 7 | @_ = ($class, @export); | |||||||||
| 36 | 7 | goto \&Exporter::import; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | |||||||||||
| 40 | 15 | ▶ | sub path { | ||||||||
|
Subroutine
path: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 41 | 15 | my @caller = caller(0); | |||||||||
| 42 | my $separator = exists $caller[10]{+__PACKAGE__} ? | ||||||||||
| 43 | 15 | ▶ | $caller[10]{+__PACKAGE__} : '/'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | 15 | my $separator_re = qr{ \Q$separator\E }x; | |||||||||
| 45 | |||||||||||
| 46 | 15 | my @paths = @_; | |||||||||
| 47 | 15 | my @path_components = map { split($separator_re, $_) } @paths; | |||||||||
| 48 | |||||||||||
| 49 | 15 | return File::Spec->catfile(@path_components); | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | |||||||||||
| 53 | 4 | *to_path = *path; | |||||||||
| 54 | |||||||||||
| 55 | |||||||||||
| 56 | 4 | 1; | |||||||||
| 57 | |||||||||||
| 58 | __END__ | ||||||||||