| 1 | package Venus::Os; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 119 | ▶ | use 5.018; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 119 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 119 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # IMPORTS | ||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 119 | ▶ | use Venus::Class 'base'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # INHERITS | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 119 | base 'Venus::Kind::Utility'; | |||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 119 | ▶ | use Encode (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 119 | our %TYPES; | |||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # BUILDERS | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub build_arg { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_arg: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | return {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # HOOKS | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | ▶ | sub _exitcode { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exitcode: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | $? >> 8; | |||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 12431 | ▶ | sub _open { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_open: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 12431 | CORE::open(shift, shift, shift); | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 898 | ▶ | sub _osname { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_osname: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 898 | ▶ | $TYPES{$^O} || $^O | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub _system { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_system: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | local $SIG{__WARN__} = sub {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | CORE::system(@_) or return 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # METHODS | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 5 | ▶ | sub call { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
call: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 5 | my ($self, $name, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 5 | ▶ | return if !$name; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 5 | require Venus::Path; | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 5 | my $which = $self->which($name); | |||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 5 | ▶ | return if !$which; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | my $path = Venus::Path->new($which); | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 4 | my $expr = join ' ', @args; | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 4 | ▶ | return $path->try('mkcall')->maybe->result($expr || ()); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$expr || ()
MC/DC0%0/2
$expr || ()
$expr
()
Truth table33%1/3
A || B
A= $exprB= ()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 73 | ▶ | sub find { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 73 | my ($self, $name, @paths) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 73 | ▶ | return if !$name; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 73 | require File::Spec; | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 73 | ▶ | return [$name] if File::Spec->splitdir($name) > 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 70 | my $result = [grep -f, map File::Spec->catfile($_, $name), @paths]; | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | return wantarray ? @{$result} : $result; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 19 | ▶ | sub is_bsd { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_bsd: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 19 | ▶ | return true if lc(_osname()) eq 'freebsd'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 18 | ▶ | return true if lc(_osname()) eq 'openbsd'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 16 | return false; | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 19 | ▶ | sub is_cyg { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_cyg: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 19 | ▶ | return true if lc(_osname()) eq 'cygwin'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 17 | ▶ | return true if lc(_osname()) eq 'msys'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 16 | return false; | |||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 12 | ▶ | sub is_dos { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_dos: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 12 | ▶ | return true if is_win(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 9 | return false; | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 19 | ▶ | sub is_lin { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_lin: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 19 | ▶ | return true if lc(_osname()) eq 'linux'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 10 | return false; | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 15 | ▶ | sub is_mac { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_mac: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 15 | ▶ | return true if lc(_osname()) eq 'macos'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 13 | ▶ | return true if lc(_osname()) eq 'darwin'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 12 | return false; | |||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 5 | ▶ | sub is_non { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_non: called CC=9 SCAR=23.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 5 | ▶ | return false if is_bsd(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 5 | ▶ | return false if is_cyg(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 5 | ▶ | return false if is_dos(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 5 | ▶ | return false if is_lin(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | ▶ | return false if is_mac(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | ▶ | return false if is_sun(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | ▶ | return false if is_vms(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | ▶ | return false if is_win(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | return true; | |||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 15 | ▶ | sub is_sun { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_sun: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 15 | ▶ | return true if lc(_osname()) eq 'solaris'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 13 | ▶ | return true if lc(_osname()) eq 'sunos'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 12 | return false; | |||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 98 | ▶ | sub is_vms { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_vms: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 98 | ▶ | return true if lc(_osname()) eq 'vms'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 96 | return false; | |||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 221 | ▶ | sub is_win { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_win: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 221 | ▶ | return true if lc(_osname()) eq 'mswin32'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 216 | ▶ | return true if lc(_osname()) eq 'dos'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 213 | ▶ | return true if lc(_osname()) eq 'os2'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 211 | return false; | |||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 2 | ▶ | sub name { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 2 | my $name = _osname(); | |||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 2 | return $name; | |||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 71 | ▶ | sub paths { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
paths: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 71 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 71 | require File::Spec; | |||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 71 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 71 | my $result = [grep !$seen{$_}++, File::Spec->path]; | |||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 71 | ▶ | return wantarray ? @{$result} : $result; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 82 | ▶ | sub quote { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quote: called CC=9 SCAR=27.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 82 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 82 | ▶ | if (!defined $data) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | elsif ($self->is_win) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | ▶ | return ($data =~ /^"/ && $data =~ /"$/) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
$data =~ /^"/u and $data =~ /"$/u
$data =~ s/"/\\"/gru || ''
MC/DC0%0/2
$data =~ /^"/u and $data =~ /"$/u
$data =~ /^"/u
$data =~ /"$/u
MC/DC0%0/1
$data =~ s/"/\\"/gru || ''
$data =~ s/"/\\"/gru
Truth table33%1/3
A and B
A= $data =~ /^"/uB= $data =~ /"$/u
Truth table50%1/2
A
A= $data =~ s/"/\\"/gru
| |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | ? $data | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | : ('"' . (($data =~ s/"/\\"/gr) || "") . '"'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 80 | ▶ | return ($data =~ /^'/ && $data =~ /'$/) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
$data =~ /^'/u and $data =~ /'$/u
$data =~ s/'/'\\''/gru || ''
MC/DC0%0/2
$data =~ /^'/u and $data =~ /'$/u
$data =~ /^'/u
$data =~ /'$/u
MC/DC0%0/1
$data =~ s/'/'\\''/gru || ''
$data =~ s/'/'\\''/gru
Truth table33%1/3
A and B
A= $data =~ /^'/uB= $data =~ /'$/u
Truth table50%1/2
A
A= $data =~ s/'/'\\''/gru
| |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | ? $data | ||||||||||||||||||||||||||||||||||||||||||||||
| 191 | : ("'" . (($data =~ s/'/'\\''/gr) || "") . "'"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 12356 | ▶ | sub read { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read: called CC=31 SCAR=36.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 12356 | my ($self, $from) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 119 | ▶ | no warnings 'io'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 12356 | my $fh; | |||||||||||||||||||||||||||||||||||||||||||||
| 201 | 12356 | ▶ | my $is_handle = ref($from) eq 'GLOB' || UNIVERSAL::isa($from, 'IO::Handle'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
ref $from eq 'GLOB' || UNIVERSAL::isa($from, 'IO::Handle')
MC/DC100%2/2
ref $from eq 'GLOB' || UNIVERSAL::isa($from, 'IO::Handle')
ref $from eq 'GLOB'
UNIVERSAL::isa($from, 'IO::Handle')
Truth table100%3/3
A || B
A= ref $from eq 'GLOB'B= UNIVERSAL::isa($from, 'IO::Handle')
| |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 12356 | my $error; | |||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 12356 | ▶ | if ($is_handle) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 2 | $fh = $from; | |||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | ▶ | binmode($fh, ':raw') or $error = $!; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 2 | ▶ | if ($error) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $self->error_on_read_binmode({from => $from, error => $error, binmode => ':raw'}) | |||||||||||||||||||||||||||||||||||||||||||||
| 209 | ->input($self, $from) | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | ->output($error) | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | ->throw; | ||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 2 | ▶ | seek($fh, 0, 0) or $error = $!; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | ▶ | if ($error) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $self->error_on_read_seek({filehandle => $fh, error => $error}) | |||||||||||||||||||||||||||||||||||||||||||||
| 216 | ->input($self, $from) | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | ->output($error) | ||||||||||||||||||||||||||||||||||||||||||||||
| 218 | ->throw; | ||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 221 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 12354 | ▶ | if (!defined $from || $from eq '-' || $from eq 'STDIN') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not defined $from or $from eq "-" or $from eq "STDIN"
not defined $from or $from eq "-"
MC/DC66%2/3
not defined $from or $from eq "-" or $from eq "STDIN"
not defined $from
$from eq "-"
$from eq "STDIN"
Truth table75%3/4
not(A) or B or C
A= not defined $fromB= $from eq "-"C= $from eq "STDIN"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 2 | ▶ | if (!defined(fileno(STDIN))) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | _open(\*STDIN, '<&', 0) or $error = $!; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if ($error) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $self->error_on_read_open_stdin({error => $error}) | |||||||||||||||||||||||||||||||||||||||||||||
| 227 | ->input($self, $from) | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | ->output($error) | ||||||||||||||||||||||||||||||||||||||||||||||
| 229 | ->throw; | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 2 | $fh = *STDIN; | |||||||||||||||||||||||||||||||||||||||||||||
| 233 | 2 | ▶ | binmode($fh, ':raw') or $error = $!; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 2 | ▶ | if ($error) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $self->error_on_read_binmode({from => 'STDIN', error => $error, binmode => ':raw'}) | |||||||||||||||||||||||||||||||||||||||||||||
| 236 | ->input($self, $from) | ||||||||||||||||||||||||||||||||||||||||||||||
| 237 | ->output($error) | ||||||||||||||||||||||||||||||||||||||||||||||
| 238 | ->throw; | ||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 12352 | ▶ | _open($fh, '<:raw', $from) or $error = $!; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 12352 | ▶ | if ($error) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 4 | $self->error_on_read_open_file({error => $error, file => $from}) | |||||||||||||||||||||||||||||||||||||||||||||
| 245 | ->input($self, $from) | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | ->output($error) | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | ->throw; | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 12352 | read($fh, my $bom, 4); | |||||||||||||||||||||||||||||||||||||||||||||
| 253 | 12352 | my $encoding; | |||||||||||||||||||||||||||||||||||||||||||||
| 254 | 12352 | my $offset = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 12352 | ▶ | if ($bom =~ /^\xEF\xBB\xBF/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 6 | $encoding = 'UTF-8'; | |||||||||||||||||||||||||||||||||||||||||||||
| 258 | 6 | $offset = 3; | |||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 260 | elsif ($bom =~ /^\xFF\xFE\x00\x00/) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 2 | $encoding = 'UTF-32LE'; | |||||||||||||||||||||||||||||||||||||||||||||
| 262 | 2 | $offset = 4; | |||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | elsif ($bom =~ /^\x00\x00\xFE\xFF/) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 2 | $encoding = 'UTF-32BE'; | |||||||||||||||||||||||||||||||||||||||||||||
| 266 | 2 | $offset = 4; | |||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 268 | elsif ($bom =~ /^\xFF\xFE/) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 2 | $encoding = 'UTF-16LE'; | |||||||||||||||||||||||||||||||||||||||||||||
| 270 | 2 | $offset = 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 272 | elsif ($bom =~ /^\xFE\xFF/) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 2 | $encoding = 'UTF-16BE'; | |||||||||||||||||||||||||||||||||||||||||||||
| 274 | 2 | $offset = 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 276 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 12338 | $encoding = 'UTF-8'; | |||||||||||||||||||||||||||||||||||||||||||||
| 278 | 12338 | ▶ | seek($fh, 0, 0) or $error = $!; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 12338 | ▶ | if ($error) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $self->error_on_read_seek_reset({error => $error}) | |||||||||||||||||||||||||||||||||||||||||||||
| 281 | ->input($self, $from) | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | ->output($error) | ||||||||||||||||||||||||||||||||||||||||||||||
| 283 | ->throw; | ||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 12352 | ▶ | if ($offset > 0) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 14 | ▶ | seek($fh, $offset, 0) or $error = $!; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 14 | ▶ | if ($error) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | $self->error_on_read_seek({error => $error}) | |||||||||||||||||||||||||||||||||||||||||||||
| 291 | ->input($self, $from) | ||||||||||||||||||||||||||||||||||||||||||||||
| 292 | ->output($error) | ||||||||||||||||||||||||||||||||||||||||||||||
| 293 | ->throw; | ||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 12352 | my $raw_content = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 12352 | ▶ | while (read($fh, my $chunk, 8192)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 143338 | $raw_content .= $chunk; | |||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 12352 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 12352 | my $data = eval { | |||||||||||||||||||||||||||||||||||||||||||||
| 306 | 12352 | Encode::decode($encoding, $raw_content, Encode::FB_CROAK); | |||||||||||||||||||||||||||||||||||||||||||||
| 307 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 12352 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $data = Encode::decode('ISO-8859-1', $raw_content); | |||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 12352 | ▶ | close $fh if !$is_handle && fileno($fh) != fileno(STDIN); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $is_handle and fileno $fh != fileno STDIN
MC/DC100%2/2
not $is_handle and fileno $fh != fileno STDIN
not $is_handle
fileno $fh != fileno STDIN
Truth table100%3/3
not(A) and B
A= not $is_handleB= fileno $fh != fileno STDIN
| |||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 12352 | $data =~ s/\r\n?/\n/g; | |||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 12352 | return $data; | |||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 2 | ▶ | sub syscall { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
syscall: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 2 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 2 | ▶ | (_system(@args) == 0) or do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 1 | my $error = $!; | |||||||||||||||||||||||||||||||||||||||||||||
| 324 | 1 | ▶ | $self->error_on_system_call({args => [@args], error => $error || _exitcode(), exit_code => _exitcode()}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$error || _exitcode()
MC/DC0%0/2
$error || _exitcode()
$error
_exitcode()
Truth table33%1/3
A || B
A= $errorB= _exitcode()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 325 | ->input($self, @args) | ||||||||||||||||||||||||||||||||||||||||||||||
| 326 | ->output($error) | ||||||||||||||||||||||||||||||||||||||||||||||
| 327 | ->throw; | ||||||||||||||||||||||||||||||||||||||||||||||
| 328 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 8 | ▶ | sub type { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 8 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 8 | my @types = qw( | |||||||||||||||||||||||||||||||||||||||||||||
| 337 | is_lin | ||||||||||||||||||||||||||||||||||||||||||||||
| 338 | is_mac | ||||||||||||||||||||||||||||||||||||||||||||||
| 339 | is_win | ||||||||||||||||||||||||||||||||||||||||||||||
| 340 | is_bsd | ||||||||||||||||||||||||||||||||||||||||||||||
| 341 | is_cyg | ||||||||||||||||||||||||||||||||||||||||||||||
| 342 | is_sun | ||||||||||||||||||||||||||||||||||||||||||||||
| 343 | is_vms | ||||||||||||||||||||||||||||||||||||||||||||||
| 344 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 8 | my $result = [grep $self->$_, @types]; | |||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 8 | ▶ | return $result->[0] || 'is_non'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$result->[0] || 'is_non'
MC/DC0%0/1
$result->[0] || 'is_non'
$result->[0]
Truth table50%1/2
A
A= $result->[0]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 70 | ▶ | sub where { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
where: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 70 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 70 | my $result = $self->find($name, $self->paths); | |||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | return wantarray ? @{$result} : $result; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 64 | ▶ | sub which { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
which: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 64 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 64 | my $result = $self->where($name); | |||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 64 | return $result->[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 87 | ▶ | sub write { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write: called CC=38 SCAR=39.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 87 | my ($self, $into, $data, $encoding) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 119 | ▶ | no warnings 'io'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 87 | ▶ | $encoding ||= Encode::is_utf8($data) ? 'UTF-8' : 'ISO-8859-1'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$encoding ||= &Encode::is_utf8($data) ? "UTF-8" : "ISO-8859-1"
MC/DC0%0/2
$encoding ||= &Encode::is_utf8($data) ? "UTF-8" : "ISO-8859-1"
$encoding
&Encode::is_utf8($data) ? "UTF-8" : "ISO-8859-1"
Truth table66%2/3
A ||= B
A= $encodingB= &Encode::is_utf8($data) ? "UTF-8" : "ISO-8859-1"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 87 | my $fh; | |||||||||||||||||||||||||||||||||||||||||||||
| 375 | 87 | ▶ | my $is_handle = ref($into) eq 'GLOB' || UNIVERSAL::isa($into, 'IO::Handle'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
ref $into eq 'GLOB' || UNIVERSAL::isa($into, 'IO::Handle')
MC/DC100%2/2
ref $into eq 'GLOB' || UNIVERSAL::isa($into, 'IO::Handle')
ref $into eq 'GLOB'
UNIVERSAL::isa($into, 'IO::Handle')
Truth table100%3/3
A || B
A= ref $into eq 'GLOB'B= UNIVERSAL::isa($into, 'IO::Handle')
| |||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 87 | my $error; | |||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 87 | ▶ | if ($is_handle) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 2 | $fh = $into; | |||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 381 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 85 | ▶ | if (!defined $into || $into eq '-' || $into eq 'STDOUT') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition83%5/6
not defined $into or $into eq "-" or $into eq "STDOUT"
not defined $into or $into eq "-"
MC/DC66%2/3
not defined $into or $into eq "-" or $into eq "STDOUT"
not defined $into
$into eq "-"
$into eq "STDOUT"
Truth table75%3/4
not(A) or B or C
A= not defined $intoB= $into eq "-"C= $into eq "STDOUT"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 4 | ▶ | if (!defined(fileno(STDOUT))) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | _open(\*STDOUT, '>&', 1) or $error = $!; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | if ($error) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | $self->error_on_write_open_stdout({error => $error}) | |||||||||||||||||||||||||||||||||||||||||||||
| 387 | ->input($self, $into, $data, $encoding) | ||||||||||||||||||||||||||||||||||||||||||||||
| 388 | ->output($error) | ||||||||||||||||||||||||||||||||||||||||||||||
| 389 | ->throw; | ||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 4 | $fh = \*STDOUT; select($fh); $| = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 394 | elsif ($into eq 'STDERR') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 2 | ▶ | if (!defined(fileno(STDERR))) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | _open(\*STDERR, '>&', 2) or $error = $!; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | if ($error) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | $self->error_on_write_open_stderr({error => $error}) | |||||||||||||||||||||||||||||||||||||||||||||
| 399 | ->input($self, $into, $data, $encoding) | ||||||||||||||||||||||||||||||||||||||||||||||
| 400 | ->output($error) | ||||||||||||||||||||||||||||||||||||||||||||||
| 401 | ->throw; | ||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 2 | $fh = \*STDERR; select($fh); $| = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 406 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 79 | ▶ | _open($fh, '>:raw', $into) or $error = $!; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 79 | ▶ | if ($error) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 3 | $self->error_on_write_open_file({error => $error, file => $into}) | |||||||||||||||||||||||||||||||||||||||||||||
| 410 | ->input($self, $into, $data, $encoding) | ||||||||||||||||||||||||||||||||||||||||||||||
| 411 | ->output($error) | ||||||||||||||||||||||||||||||||||||||||||||||
| 412 | ->throw; | ||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 84 | ▶ | if (fileno($fh) == fileno(STDOUT) || fileno($fh) == fileno(STDERR)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
fileno $fh == fileno STDOUT or fileno $fh == fileno STDERR
MC/DC100%2/2
fileno $fh == fileno STDOUT or fileno $fh == fileno STDERR
fileno $fh == fileno STDOUT
fileno $fh == fileno STDERR
Truth table100%3/3
A or B
A= fileno $fh == fileno STDOUTB= fileno $fh == fileno STDERR
| |||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 6 | ▶ | binmode($fh, ":raw") or $error = $!; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 6 | ▶ | if ($error) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | $self->error_on_write_binmode({from => 'STOUT', error => $error, binmode => ':raw'}) | |||||||||||||||||||||||||||||||||||||||||||||
| 421 | ->input($self, $into, $data, $encoding) | ||||||||||||||||||||||||||||||||||||||||||||||
| 422 | ->output($error) | ||||||||||||||||||||||||||||||||||||||||||||||
| 423 | ->throw; | ||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 426 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 78 | ▶ | binmode($fh, ':raw') or $error = $!; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 78 | ▶ | if ($error) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | $self->error_on_write_binmode({from => $fh, error => $error, binmode => ':raw'}) | |||||||||||||||||||||||||||||||||||||||||||||
| 430 | ->input($self, $into, $data, $encoding) | ||||||||||||||||||||||||||||||||||||||||||||||
| 431 | ->output($error) | ||||||||||||||||||||||||||||||||||||||||||||||
| 432 | ->throw; | ||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 78 | ▶ | if ($encoding eq 'UTF-8') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 7 | print $fh "\xEF\xBB\xBF"; | |||||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 438 | elsif ($encoding eq 'UTF-16LE') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 1 | print $fh "\xFF\xFE"; | |||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 441 | elsif ($encoding eq 'UTF-16BE') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 1 | print $fh "\xFE\xFF"; | |||||||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 444 | elsif ($encoding eq 'UTF-32LE') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 1 | print $fh "\xFF\xFE\x00\x00"; | |||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 447 | elsif ($encoding eq 'UTF-32BE') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 1 | print $fh "\x00\x00\xFE\xFF"; | |||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 84 | ▶ | $data = "" if !defined $data; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 84 | ▶ | if ($self->is_vms || $self->is_win) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->is_vms or $self->is_win
MC/DC0%0/2
$self->is_vms or $self->is_win
$self->is_vms
$self->is_win
Truth table33%1/3
A or B
A= $self->is_vmsB= $self->is_win
| |||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | $data =~ s/(?<!\r)\n/\r\n/g; | |||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 84 | ▶ | if (fileno($fh) == fileno(STDOUT) || fileno($fh) == fileno(STDERR)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
fileno $fh == fileno STDOUT or fileno $fh == fileno STDERR
MC/DC100%2/2
fileno $fh == fileno STDOUT or fileno $fh == fileno STDERR
fileno $fh == fileno STDOUT
fileno $fh == fileno STDERR
Truth table100%3/3
A or B
A= fileno $fh == fileno STDOUTB= fileno $fh == fileno STDERR
| |||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 6 | ▶ | my $encoded_content = Encode::is_utf8($data) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 460 | ? "$data" | ||||||||||||||||||||||||||||||||||||||||||||||
| 461 | : Encode::encode('UTF-8', $data, Encode::FB_CROAK); | ||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 6 | print $fh $encoded_content; | |||||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 464 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 78 | my $encoded_content = Encode::encode($encoding, $data, Encode::FB_CROAK); | |||||||||||||||||||||||||||||||||||||||||||||
| 466 | 78 | my $chunk_size = 8192; | |||||||||||||||||||||||||||||||||||||||||||||
| 467 | 78 | my $offset = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 468 | 78 | my $length = length($encoded_content); | |||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 78 | ▶ | while ($offset < $length) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 94 | my $chunk = substr($encoded_content, $offset, $chunk_size); | |||||||||||||||||||||||||||||||||||||||||||||
| 472 | 94 | print $fh $chunk; | |||||||||||||||||||||||||||||||||||||||||||||
| 473 | 94 | $offset += $chunk_size; | |||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 84 | ▶ | close $fh | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
not $is_handle and (fileno $fh != fileno STDOUT and fileno $fh != fileno STDERR)
fileno $fh != fileno STDOUT and fileno $fh != fileno STDERR
MC/DC100%3/3
not $is_handle and (fileno $fh != fileno STDOUT and fileno $fh != fileno STDERR)
not $is_handle
fileno $fh != fileno STDOUT
fileno $fh != fileno STDERR
Truth table100%4/4
not(A) and B and C
A= not $is_handleB= fileno $fh != fileno STDOUTC= fileno $fh != fileno STDERR
| |||||||||||||||||||||||||||||||||||||||||||||||
| 478 | if !$is_handle | ||||||||||||||||||||||||||||||||||||||||||||||
| 479 | && (fileno($fh) != fileno(STDOUT) && fileno($fh) != fileno(STDERR)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 84 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||
| 484 | # ERRORS | ||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | sub error_on_read_binmode { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_on_read_binmode: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | my $error = $self->error->sysinfo; | |||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | my $message = 'Can\'t binmode on read: {{error}}'; | |||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | $error->name('on.read.binmode'); | |||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | $error->message($message); | |||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | $error->offset(1); | |||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | $error->stash($data); | |||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | $error->reset; | |||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | return $error; | |||||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 4 | ▶ | sub error_on_read_open_file { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_on_read_open_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 4 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 4 | my $error = $self->error->sysinfo; | |||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 4 | my $message = 'Can\'t open "{{file}}" for reading: {{error}}'; | |||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 4 | $error->name('on.read.open.file'); | |||||||||||||||||||||||||||||||||||||||||||||
| 510 | 4 | $error->message($message); | |||||||||||||||||||||||||||||||||||||||||||||
| 511 | 4 | $error->offset(1); | |||||||||||||||||||||||||||||||||||||||||||||
| 512 | 4 | $error->stash($data); | |||||||||||||||||||||||||||||||||||||||||||||
| 513 | 4 | $error->reset; | |||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 4 | return $error; | |||||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | ▶ | sub error_on_read_open_stdin { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_on_read_open_stdin: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | my $error = $self->error->sysinfo; | |||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | my $message = 'Can\'t open STDIN for reading: {{error}}'; | |||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | $error->name('on.read.open.stdin'); | |||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | $error->message($message); | |||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | $error->offset(1); | |||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | $error->stash($data); | |||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | $error->reset; | |||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | return $error; | |||||||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | sub error_on_read_seek { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_on_read_seek: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | my $error = $self->error->sysinfo; | |||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | my $message = 'Can\'t seek in filehandle: {{error}}'; | |||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | $error->name('on.read.seek'); | |||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | $error->message($message); | |||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | $error->offset(1); | |||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | $error->stash($data); | |||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | $error->reset; | |||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | return $error; | |||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | sub error_on_read_seek_reset { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_on_read_seek_reset: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | my $error = $self->error->sysinfo; | |||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | my $message = 'Can\'t reset seek in filehandle: {{error}}'; | |||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | $error->name('on.read.seek.reset'); | |||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | $error->message($message); | |||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | $error->offset(1); | |||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | $error->stash($data); | |||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | $error->reset; | |||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | return $error; | |||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 1 | ▶ | sub error_on_system_call { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_on_system_call: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 1 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 1 | my $error = $self->error->sysinfo; | |||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 1 | my $message = 'Can\'t make system call "{{command}}": {{error}}'; | |||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 1 | $data->{command} = join ' ', @{$data->{args}}; | |||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 1 | $error->name('on.system.call'); | |||||||||||||||||||||||||||||||||||||||||||||
| 576 | 1 | $error->message($message); | |||||||||||||||||||||||||||||||||||||||||||||
| 577 | 1 | $error->offset(1); | |||||||||||||||||||||||||||||||||||||||||||||
| 578 | 1 | $error->stash($data); | |||||||||||||||||||||||||||||||||||||||||||||
| 579 | 1 | $error->reset; | |||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 1 | return $error; | |||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | sub error_on_write_binmode { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_on_write_binmode: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | my $error = $self->error->sysinfo; | |||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | my $message = 'Can\'t binmode on write: {{error}}'; | |||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | $error->name('on.write.binmode'); | |||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | $error->message($message); | |||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | $error->offset(1); | |||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | $error->stash($data); | |||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | $error->reset; | |||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | return $error; | |||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 3 | ▶ | sub error_on_write_open_file { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_on_write_open_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 3 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 3 | my $error = $self->error->sysinfo; | |||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 3 | my $message = 'Can\'t open "{{file}}" for writing: {{error}}'; | |||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 3 | $error->name('on.write.open.file'); | |||||||||||||||||||||||||||||||||||||||||||||
| 608 | 3 | $error->message($message); | |||||||||||||||||||||||||||||||||||||||||||||
| 609 | 3 | $error->offset(1); | |||||||||||||||||||||||||||||||||||||||||||||
| 610 | 3 | $error->stash($data); | |||||||||||||||||||||||||||||||||||||||||||||
| 611 | 3 | $error->reset; | |||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 3 | return $error; | |||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | ▶ | sub error_on_write_open_stderr { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_on_write_open_stderr: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | my $error = $self->error->sysinfo; | |||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | my $message = 'Can\'t open STDERR for writing: {{error}}'; | |||||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | $error->name('on.write.open.stderr'); | |||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | $error->message($message); | |||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | $error->offset(1); | |||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | $error->stash($data); | |||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | $error->reset; | |||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | return $error; | |||||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | ▶ | sub error_on_write_open_stdout { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_on_write_open_stdout: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | my $error = $self->error->sysinfo; | |||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | my $message = 'Can\'t open STDOUT for writing: {{error}}'; | |||||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | $error->name('on.write.open.stdout'); | |||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | $error->message($message); | |||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | $error->offset(1); | |||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | $error->stash($data); | |||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | $error->reset; | |||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | return $error; | |||||||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 119 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||
| 652 | =encoding UTF8 | ||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||
| 654 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||
| 656 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||
| 658 | Venus::Os - OS Class | ||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||
| 660 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||
| 662 | =head1 ABSTRACT | ||||||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||||||
| 664 | OS Class for Perl 5 | ||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||
| 666 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||
| 668 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||
| 670 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||
| 672 | use Venus::Os; | ||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||
| 674 | my $os = Venus::Os->new; | ||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||
| 676 | # bless({...}, 'Venus::Os') | ||||||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||||||
| 678 | # my $name = $os->name; | ||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||
| 680 | # "linux" | ||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||
| 682 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||
| 684 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||
| 686 | This package provides methods for determining the current operating system, as | ||||||||||||||||||||||||||||||||||||||||||||||
| 687 | well as finding and executing files. | ||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||
| 689 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||||||
| 691 | =head1 INHERITS | ||||||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||||||
| 693 | This package inherits behaviors from: | ||||||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||||||
| 695 | L<Venus::Kind::Utility> | ||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||
| 697 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||||||
| 699 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||
| 701 | This package provides the following methods: | ||||||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||||||
| 703 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||
| 705 | =head2 call | ||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||
| 707 | call(string $name, string @args) (any) | ||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||
| 709 | The call method attempts to find the path to the program specified via | ||||||||||||||||||||||||||||||||||||||||||||||
| 710 | L</which> and dispatches to L<Venus::Path/mkcall> and returns the result. Any | ||||||||||||||||||||||||||||||||||||||||||||||
| 711 | exception throw is supressed and will return undefined if encountered. | ||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||
| 713 | I<Since C<2.80>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||
| 715 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||||||
| 717 | =item call example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||
| 719 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||
| 721 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||
| 723 | my $app = $os->is_win ? 'perl.exe' : 'perl'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||
| 725 | my $call = $os->call($app, '-V:osname'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||
| 727 | # "osname='linux';" | ||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||
| 729 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||
| 731 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||
| 733 | =item call example 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||
| 735 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||||||
| 737 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||
| 739 | my $app = $os->is_win ? 'perl.exe' : 'perl'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||
| 741 | my @call = $os->call($app, '-V:osname'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||||||
| 743 | # ("osname='linux';", 0) | ||||||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||||||
| 745 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||
| 747 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||
| 749 | =item call example 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||
| 751 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||
| 753 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||||||
| 755 | my $call = $os->call('nowhere'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||||||
| 757 | # undef | ||||||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||||||
| 759 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||
| 761 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||
| 763 | =item call example 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||
| 765 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||||||
| 767 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||||||
| 769 | my @call = $os->call($^X, '-V:osname'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||
| 771 | # ("osname='linux';", 0) | ||||||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||||||
| 773 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||||||
| 775 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||
| 777 | =item call example 5 | ||||||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||||||
| 779 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||||||
| 781 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||||||
| 783 | my @call = $os->call($^X, 't/data/sun'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||||||
| 785 | # ("", 1) | ||||||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||||||
| 787 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||||||
| 789 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||||||
| 791 | =head2 find | ||||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||
| 793 | find(string $name, string @paths) (arrayref) | ||||||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||||||
| 795 | The find method searches the paths provided for a file matching the name | ||||||||||||||||||||||||||||||||||||||||||||||
| 796 | provided and returns all the files found as an arrayref. Returns a list in list | ||||||||||||||||||||||||||||||||||||||||||||||
| 797 | context. | ||||||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||||||
| 799 | I<Since C<2.80>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||||||
| 801 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||||||
| 803 | =item find example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||||||
| 805 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||||||
| 807 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||||||
| 809 | my $find = $os->find('cmd', 't/path/user/bin'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||||||
| 811 | # ["t/path/user/bin/cmd"] | ||||||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||||||
| 813 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||
| 815 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||||||
| 817 | =item find example 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||
| 819 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||||||
| 821 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||
| 823 | my $find = $os->find('cmd', 't/path/user/bin', 't/path/usr/bin'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||||||
| 825 | # ["t/path/user/bin/cmd", "t/path/usr/bin/cmd"] | ||||||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||||||
| 827 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||||||
| 829 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||||||
| 831 | =item find example 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||||||
| 833 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||||||
| 835 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||||||
| 837 | my $find = $os->find('zzz', 't/path/user/bin', 't/path/usr/bin'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||||||
| 839 | # [] | ||||||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||||||
| 841 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||||||
| 843 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||||||
| 845 | =head2 is_bsd | ||||||||||||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||||||||||||
| 847 | is_bsd() (boolean) | ||||||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||||||
| 849 | The is_bsd method returns true if the OS is either C<"freebsd"> or | ||||||||||||||||||||||||||||||||||||||||||||||
| 850 | C<"openbsd">, and otherwise returns false. | ||||||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||||||
| 852 | I<Since C<2.80>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||||||
| 854 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||||||
| 856 | =item is_bsd example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||||||
| 858 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||||||
| 860 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||||||
| 862 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||||||||||||||||
| 864 | my $is_bsd = $os->is_bsd; | ||||||||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||||||
| 866 | # false | ||||||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||||||
| 868 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||
| 870 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||||||
| 872 | =item is_bsd example 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||||||
| 874 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||||||
| 876 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||||||||||||
| 878 | # on freebsd | ||||||||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||||||
| 880 | my $is_bsd = $os->is_bsd; | ||||||||||||||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||||||||||||||
| 882 | # true | ||||||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||||||
| 884 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||||||
| 886 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||||||
| 888 | =item is_bsd example 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||||||
| 890 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||||||
| 892 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||||||
| 894 | # on openbsd | ||||||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||||||
| 896 | my $is_bsd = $os->is_bsd; | ||||||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||||||
| 898 | # true | ||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||
| 900 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||||||
| 902 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||||||
| 904 | =head2 is_cyg | ||||||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||||||
| 906 | is_cyg() (boolean) | ||||||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||||||
| 908 | The is_cyg method returns true if the OS is either C<"cygwin"> or C<"msys">, | ||||||||||||||||||||||||||||||||||||||||||||||
| 909 | and otherwise returns false. | ||||||||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||||||
| 911 | I<Since C<2.80>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||||||||||||||||
| 913 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||||||
| 915 | =item is_cyg example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||||||
| 917 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||
| 919 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||||||
| 921 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||||||
| 923 | my $is_cyg = $os->is_cyg; | ||||||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||||||
| 925 | # false | ||||||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||||||
| 927 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||||||
| 929 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||||||||||||||
| 931 | =item is_cyg example 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||
| 933 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||||||
| 935 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||||||
| 937 | # on cygwin | ||||||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||||||
| 939 | my $is_cyg = $os->is_cyg; | ||||||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||||||
| 941 | # true | ||||||||||||||||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||||||||||||||||
| 943 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||||||
| 945 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||||||
| 947 | =item is_cyg example 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||||||
| 949 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||||||
| 951 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||||||
| 953 | # on msys | ||||||||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||||||
| 955 | my $is_cyg = $os->is_cyg; | ||||||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||||||
| 957 | # true | ||||||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||||||
| 959 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||||||
| 961 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||||||
| 963 | =head2 is_dos | ||||||||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||||||
| 965 | is_dos() (boolean) | ||||||||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||||||
| 967 | The is_dos method returns true if the OS is either C<"mswin32"> or C<"dos"> or | ||||||||||||||||||||||||||||||||||||||||||||||
| 968 | C<"os2">, and otherwise returns false. | ||||||||||||||||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||||||||||||||||
| 970 | I<Since C<2.80>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||||||
| 972 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||
| 974 | =item is_dos example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||||||
| 976 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||||||
| 978 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||||||
| 980 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||||||||||||||||||||
| 982 | my $is_dos = $os->is_dos; | ||||||||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||||||
| 984 | # false | ||||||||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||||||
| 986 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||||||||||||||||||||
| 988 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||||||
| 990 | =item is_dos example 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||||||
| 992 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||||||||||||||||
| 994 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||||||
| 996 | # on mswin32 | ||||||||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||||||
| 998 | my $is_dos = $os->is_dos; | ||||||||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | # true | ||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | =item is_dos example 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | # on dos | ||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | my $is_dos = $os->is_dos; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | # true | ||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | =item is_dos example 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | # on os2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | my $is_dos = $os->is_dos; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | # true | ||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | =head2 is_lin | ||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | is_lin() (boolean) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | The is_lin method returns true if the OS is C<"linux">, and otherwise returns | ||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | false. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | I<Since C<2.80>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | =item is_lin example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | my $is_lin = $os->is_lin; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | # true | ||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | =item is_lin example 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | # on macos | ||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | my $is_lin = $os->is_lin; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | # false | ||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | =item is_lin example 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | # on mswin32 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | my $is_lin = $os->is_lin; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | # false | ||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | =head2 is_mac | ||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | is_mac() (boolean) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | The is_mac method returns true if the OS is either C<"macos"> or C<"darwin">, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | and otherwise returns false. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | I<Since C<2.80>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | =item is_mac example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | my $is_mac = $os->is_mac; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | # false | ||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | =item is_mac example 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | # on macos | ||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | my $is_mac = $os->is_mac; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | # true | ||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | =item is_mac example 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | # on darwin | ||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | my $is_mac = $os->is_mac; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | # true | ||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | =head2 is_non | ||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | is_non() (boolean) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | The is_non method returns true if the OS is not recognized, and if recognized | ||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | returns false. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | I<Since C<2.80>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | =item is_non example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | my $is_non = $os->is_non; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | # false | ||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | =item is_non example 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | # on aix | ||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | my $is_non = $os->is_non; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | # true | ||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | =head2 is_sun | ||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | is_sun() (boolean) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | The is_sun method returns true if the OS is either C<"solaris"> or C<"sunos">, | ||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | and otherwise returns false. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | I<Since C<2.80>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | =item is_sun example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | my $is_sun = $os->is_sun; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | # false | ||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | =item is_sun example 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | # on solaris | ||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | my $is_sun = $os->is_sun; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | # true | ||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | =item is_sun example 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | # on sunos | ||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | my $is_sun = $os->is_sun; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | # true | ||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | =head2 is_vms | ||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | is_vms() (boolean) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | The is_vms method returns true if the OS is C<"vms">, and otherwise returns | ||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | false. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | I<Since C<2.80>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | =item is_vms example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | my $is_vms = $os->is_vms; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | # false | ||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | =item is_vms example 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | # on vms | ||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | my $is_vms = $os->is_vms; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | # true | ||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | =head2 is_win | ||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | is_win() (boolean) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | The is_win method returns true if the OS is either C<"mswin32"> or C<"dos"> or | ||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | C<"os2">, and otherwise returns false. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | I<Since C<2.80>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | =item is_win example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | my $is_win = $os->is_win; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | # false | ||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | =item is_win example 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | # on mswin32 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | my $is_win = $os->is_win; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | # true | ||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | =item is_win example 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | # on dos | ||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | my $is_win = $os->is_win; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | # true | ||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | =item is_win example 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | # on os2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | my $is_win = $os->is_win; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | # true | ||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | =head2 name | ||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | name() (string) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | The name method returns the OS name. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | I<Since C<2.80>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | =item name example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | my $name = $os->name; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | # "linux" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | # same as $^O | ||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | new(any @args) (Venus::Os) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | The new method constructs an instance of the package. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | =item new example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | use Venus::Os; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | my $new = Venus::Os->new; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | # bless(..., "Venus::Os") | ||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | =head2 paths | ||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | paths() (arrayref) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | The paths method returns the paths specified by the C<"PATH"> environment | ||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | variable as an arrayref of unique paths. Returns a list in list context. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | I<Since C<2.80>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | =item paths example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | my $paths = $os->paths; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | # [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | # "/root/local/bin", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | # "/root/bin", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | # "/usr/local/sbin", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | # "/usr/local/bin", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | # "/usr/sbin:/usr/bin", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | # ] | ||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | =head2 quote | ||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | quote(string $data) (string) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | The quote method accepts a string and returns the OS-specific quoted version of | ||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | the string. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | I<Since C<2.91>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | =item quote example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | my $quote = $os->quote("hello \"world\""); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | # "'hello \"world\"'" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | =item quote example 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | my $quote = $os->quote('hello \'world\''); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | # "'hello '\\''world'\\'''" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | =item quote example 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | # on mswin32 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | my $quote = $os->quote("hello \"world\""); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | # "\"hello \\"world\\"\"" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | =item quote example 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | # on mswin32 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | my $quote = $os->quote('hello "world"'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | # '"hello \"world\""' | ||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | =head2 read | ||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | read(any $from) (string) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | The read method reads from a file, filehandle, or STDIN, and returns the data. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | To read from STDIN provide the string C<"STDIN">. The method defaults to reading from STDIN. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | =item read example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | my $read = $os->read; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | # from STDIN | ||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | # "..." | ||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | =item read example 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | my $read = $os->read('STDIN'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | # from STDIN | ||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | # "..." | ||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | =item read example 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | my $read = $os->read('t/data/texts/iso-8859-1.txt'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | # from file | ||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | # "Hello, world! This is ISO-8859-1." | ||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | =item read example 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | open my $fh, '<', 't/data/texts/iso-8859-1.txt'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | my $read = $os->read($fh); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | # from filehandle | ||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | # "Hello, world! This is ISO-8859-1." | ||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | =item read example 5 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | use IO::File; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | my $fh = IO::File->new('t/data/texts/iso-8859-1.txt', 'r'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | my $read = $os->read($fh); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | # from filehandle | ||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | # "Hello, world! This is ISO-8859-1." | ||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | =item read example 6 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | my $read = $os->read('t/data/texts/utf-16be.txt'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | # from UTF-16BE encoded file | ||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | # "Hello, world! こんにちは世界!" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | =item read example 7 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | my $read = $os->read('t/data/texts/utf-16le.txt'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | # from UTF-16LE encoded file | ||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | # "Hello, world! こんにちは世界!" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | =item read example 8 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | my $read = $os->read('t/data/texts/utf-32be.txt'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | # from UTF-32BE encoded file | ||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | # "Hello, world! こんにちは世界!" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | =item read example 9 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | my $read = $os->read('t/data/texts/utf-32le.txt'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | # from UTF-32LE encoded file | ||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | # "Hello, world! こんにちは世界!" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | =item read example 10 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | my $read = $os->read('t/data/texts/utf-8.txt'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | # from UTF-8 encoded file | ||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | # "Hello, world! こんにちは世界!" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | =item B<may raise> L<Venus::Os::Error> C<on.read.open.file> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | $os->read('/path/to/nowhere'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | # Error! (on.read.open.file) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | =head2 syscall | ||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | syscall(any @data) (Venus::Os) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | The syscall method executes the command and arguments provided, via | ||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | L<perlfunc/system>, and returns the invocant. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | =item syscall example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | use Venus::Os; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | my $os = Venus::Os->new; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | $os->syscall($^X, '--help'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | # bless(..., "Venus::Os") | ||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | =item syscall example 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | use Venus::Os; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | my $os = Venus::Os->new; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | $os->syscall('.help'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | # Exception! (isa Venus::Os::Error) (see error_on_system_call) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | =head2 type | ||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | type() (string) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | The type method returns a string representing the "test" method, which | ||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | identifies the OS, that would return true if called, based on the name of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | OS. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | I<Since C<2.80>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | =item type example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | my $type = $os->type; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | # "is_lin" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | =item type example 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | # on macos | ||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | my $type = $os->type; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | # "is_mac" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | =item type example 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | # on mswin32 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | my $type = $os->type; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | # "is_win" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1841 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1844 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1845 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | =item type example 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1847 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1848 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1849 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1850 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1851 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1852 | # on openbsd | ||||||||||||||||||||||||||||||||||||||||||||||
| 1853 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1854 | my $type = $os->type; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1855 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1856 | # "is_bsd" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1857 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1858 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1859 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1860 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1861 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1862 | =item type example 5 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1863 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1864 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1865 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1866 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1867 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1868 | # on cygwin | ||||||||||||||||||||||||||||||||||||||||||||||
| 1869 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1870 | my $type = $os->type; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1871 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1872 | # "is_cyg" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1873 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1874 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1875 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1876 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1877 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1878 | =item type example 6 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1879 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1880 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1881 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1882 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1883 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1884 | # on dos | ||||||||||||||||||||||||||||||||||||||||||||||
| 1885 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1886 | my $type = $os->type; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1887 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1888 | # "is_win" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1889 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1890 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1891 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1892 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1893 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1894 | =item type example 7 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1895 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1896 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1897 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1898 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1899 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1900 | # on solaris | ||||||||||||||||||||||||||||||||||||||||||||||
| 1901 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1902 | my $type = $os->type; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1903 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1904 | # "is_sun" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1905 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1906 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1907 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1908 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1909 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1910 | =item type example 8 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1911 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1912 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1913 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1914 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1915 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1916 | # on vms | ||||||||||||||||||||||||||||||||||||||||||||||
| 1917 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1918 | my $type = $os->type; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1919 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1920 | # "is_vms" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1921 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1922 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1923 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1924 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 1925 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1926 | =head2 where | ||||||||||||||||||||||||||||||||||||||||||||||
| 1927 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1928 | where(string $file) (arrayref) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1929 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1930 | The where method searches the paths defined by the C<PATH> environment variable | ||||||||||||||||||||||||||||||||||||||||||||||
| 1931 | for a file matching the name provided and returns all the files found as an | ||||||||||||||||||||||||||||||||||||||||||||||
| 1932 | arrayref. Returns a list in list context. This method doesn't check (or care) | ||||||||||||||||||||||||||||||||||||||||||||||
| 1933 | if the files found are actually executable. | ||||||||||||||||||||||||||||||||||||||||||||||
| 1934 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1935 | I<Since C<2.80>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 1936 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1937 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1938 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1939 | =item where example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1940 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1941 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1942 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1943 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1944 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1945 | my $where = $os->where('cmd'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1946 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1947 | # [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 1948 | # "t/path/user/local/bin/cmd", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1949 | # "t/path/user/bin/cmd", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1950 | # "t/path/usr/bin/cmd", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1951 | # "t/path/usr/local/bin/cmd", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1952 | # "t/path/usr/local/sbin/cmd", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1953 | # "t/path/usr/sbin/cmd" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1954 | # ] | ||||||||||||||||||||||||||||||||||||||||||||||
| 1955 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1956 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1957 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1958 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1959 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1960 | =item where example 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1961 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1962 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1963 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1964 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1965 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1966 | my $where = $os->where('app1'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1967 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1968 | # [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 1969 | # "t/path/user/local/bin/app1", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1970 | # "t/path/usr/bin/app1", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1971 | # "t/path/usr/sbin/app1" | ||||||||||||||||||||||||||||||||||||||||||||||
| 1972 | # ] | ||||||||||||||||||||||||||||||||||||||||||||||
| 1973 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1974 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1975 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1976 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1977 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1978 | =item where example 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1979 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1980 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1981 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1982 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1983 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1984 | my $where = $os->where('app2'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1985 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1986 | # [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 1987 | # "t/path/user/local/bin/app2", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1988 | # "t/path/usr/bin/app2", | ||||||||||||||||||||||||||||||||||||||||||||||
| 1989 | # ] | ||||||||||||||||||||||||||||||||||||||||||||||
| 1990 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1991 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 1992 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1993 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1994 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1995 | =item where example 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 1996 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1997 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 1998 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1999 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2000 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2001 | my $where = $os->where('app3'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2002 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2003 | # [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 2004 | # "t/path/user/bin/app3", | ||||||||||||||||||||||||||||||||||||||||||||||
| 2005 | # "t/path/usr/sbin/app3" | ||||||||||||||||||||||||||||||||||||||||||||||
| 2006 | # ] | ||||||||||||||||||||||||||||||||||||||||||||||
| 2007 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2008 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2009 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2010 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2011 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2012 | =item where example 5 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2013 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2014 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2015 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2016 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2017 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2018 | my $where = $os->where('app4'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2019 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2020 | # [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 2021 | # "t/path/user/local/bin/app4", | ||||||||||||||||||||||||||||||||||||||||||||||
| 2022 | # "t/path/usr/local/bin/app4", | ||||||||||||||||||||||||||||||||||||||||||||||
| 2023 | # "t/path/usr/local/sbin/app4", | ||||||||||||||||||||||||||||||||||||||||||||||
| 2024 | # ] | ||||||||||||||||||||||||||||||||||||||||||||||
| 2025 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2026 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2027 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2028 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2029 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2030 | =item where example 6 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2031 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2032 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2033 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2034 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2035 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2036 | my $where = $os->where('app5'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2037 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2038 | # [] | ||||||||||||||||||||||||||||||||||||||||||||||
| 2039 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2040 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2041 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2042 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 2043 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2044 | =head2 which | ||||||||||||||||||||||||||||||||||||||||||||||
| 2045 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2046 | which(string $file) (string) | ||||||||||||||||||||||||||||||||||||||||||||||
| 2047 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2048 | The which method returns the first match from the result of calling the | ||||||||||||||||||||||||||||||||||||||||||||||
| 2049 | L</where> method with the arguments provided. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2050 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2051 | I<Since C<2.80>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 2052 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2053 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2054 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2055 | =item which example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2056 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2057 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2058 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2059 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2060 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2061 | my $which = $os->which('cmd'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2062 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2063 | # "t/path/user/local/bin/cmd", | ||||||||||||||||||||||||||||||||||||||||||||||
| 2064 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2065 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2066 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2067 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2068 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2069 | =item which example 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2070 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2071 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2072 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2073 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2074 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2075 | my $which = $os->which('app1'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2076 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2077 | # "t/path/user/local/bin/app1" | ||||||||||||||||||||||||||||||||||||||||||||||
| 2078 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2079 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2080 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2081 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2082 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2083 | =item which example 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2084 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2085 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2086 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2087 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2088 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2089 | my $which = $os->which('app2'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2090 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2091 | # "t/path/user/local/bin/app2" | ||||||||||||||||||||||||||||||||||||||||||||||
| 2092 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2093 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2094 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2095 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2096 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2097 | =item which example 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2098 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2099 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2100 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2101 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2102 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2103 | my $which = $os->which('app3'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2104 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2105 | # "t/path/user/bin/app3" | ||||||||||||||||||||||||||||||||||||||||||||||
| 2106 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2107 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2108 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2109 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2110 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2111 | =item which example 5 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2112 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2113 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2114 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2115 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2116 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2117 | my $which = $os->which('app4'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2118 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2119 | # "t/path/user/local/bin/app4" | ||||||||||||||||||||||||||||||||||||||||||||||
| 2120 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2121 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2122 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2123 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2124 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2125 | =item which example 6 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2126 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2127 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2128 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2129 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2130 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2131 | my $which = $os->which('app5'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2132 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2133 | # undef | ||||||||||||||||||||||||||||||||||||||||||||||
| 2134 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2135 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2136 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2137 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 2138 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2139 | =head2 write | ||||||||||||||||||||||||||||||||||||||||||||||
| 2140 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2141 | write(any $into, string $data, string $encoding) (Venus::Os) | ||||||||||||||||||||||||||||||||||||||||||||||
| 2142 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2143 | The write method writes to a file, filehandle, STDOUT, or STDERR, and returns | ||||||||||||||||||||||||||||||||||||||||||||||
| 2144 | the invocant. To write to STDOUT provide the string C<"STDOUT">. To write to | ||||||||||||||||||||||||||||||||||||||||||||||
| 2145 | STDERR provide the string C<"STDERR">. The method defaults to writing to | ||||||||||||||||||||||||||||||||||||||||||||||
| 2146 | STDOUT. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2147 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2148 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||
| 2149 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2150 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2151 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2152 | =item write example 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2154 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2155 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2156 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2157 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2158 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 2159 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2160 | my $write = $os->write; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2161 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2162 | # to STDOUT | ||||||||||||||||||||||||||||||||||||||||||||||
| 2163 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2164 | # '' | ||||||||||||||||||||||||||||||||||||||||||||||
| 2165 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2166 | # bless(..., "Venus::Os") | ||||||||||||||||||||||||||||||||||||||||||||||
| 2167 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2168 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2169 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2170 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2171 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2172 | =item write example 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2173 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2174 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2175 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2176 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2177 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2178 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 2179 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2180 | my $write = $os->write(undef, ''); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2181 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2182 | # to STDOUT | ||||||||||||||||||||||||||||||||||||||||||||||
| 2183 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2184 | # '' | ||||||||||||||||||||||||||||||||||||||||||||||
| 2185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2186 | # bless(..., "Venus::Os") | ||||||||||||||||||||||||||||||||||||||||||||||
| 2187 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2188 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2189 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2190 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2191 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2192 | =item write example 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2193 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2194 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2195 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2196 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2197 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2198 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 2199 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2200 | my $write = $os->write('STDOUT'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2201 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2202 | # to STDOUT | ||||||||||||||||||||||||||||||||||||||||||||||
| 2203 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2204 | # '' | ||||||||||||||||||||||||||||||||||||||||||||||
| 2205 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2206 | # bless(..., "Venus::Os") | ||||||||||||||||||||||||||||||||||||||||||||||
| 2207 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2208 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2209 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2210 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2211 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2212 | =item write example 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2213 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2214 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2215 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2216 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2217 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2218 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 2219 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2220 | my $write = $os->write('STDOUT', '...'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2221 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2222 | # to STDOUT | ||||||||||||||||||||||||||||||||||||||||||||||
| 2223 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2224 | # '...' | ||||||||||||||||||||||||||||||||||||||||||||||
| 2225 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2226 | # bless(..., "Venus::Os") | ||||||||||||||||||||||||||||||||||||||||||||||
| 2227 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2228 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2229 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2230 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2231 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2232 | =item write example 5 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2233 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2234 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2235 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2236 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2237 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2238 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 2239 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2240 | my $write = $os->write('STDERR'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2241 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2242 | # to STDERR | ||||||||||||||||||||||||||||||||||||||||||||||
| 2243 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2244 | # '' | ||||||||||||||||||||||||||||||||||||||||||||||
| 2245 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2246 | # bless(..., "Venus::Os") | ||||||||||||||||||||||||||||||||||||||||||||||
| 2247 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2248 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2249 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2250 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2251 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2252 | =item write example 6 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2253 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2254 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2255 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2256 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2257 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2258 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 2259 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2260 | my $write = $os->write('STDERR', '...'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2261 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2262 | # to STDERR | ||||||||||||||||||||||||||||||||||||||||||||||
| 2263 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2264 | # '...' | ||||||||||||||||||||||||||||||||||||||||||||||
| 2265 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2266 | # bless(..., "Venus::Os") | ||||||||||||||||||||||||||||||||||||||||||||||
| 2267 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2268 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2269 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2270 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2271 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2272 | =item write example 7 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2273 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2274 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2275 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2276 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2277 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2278 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 2279 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2280 | my $file = 't/data/texts/iso-8859-1.txt'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2281 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2282 | my $write = $os->write($file, 'Hello, world! This is ISO-8859-1.'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2283 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2284 | # to file | ||||||||||||||||||||||||||||||||||||||||||||||
| 2285 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2286 | # "Hello, world! This is ISO-8859-1." | ||||||||||||||||||||||||||||||||||||||||||||||
| 2287 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2288 | # bless(..., "Venus::Os") | ||||||||||||||||||||||||||||||||||||||||||||||
| 2289 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2290 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2291 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2292 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2293 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2294 | =item write example 8 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2295 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2296 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2297 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2298 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2299 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2300 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 2301 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2302 | open my $fh, '<', 't/data/texts/iso-8859-1.txt'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2303 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2304 | my $write = $os->write($fh, 'Hello, world! This is ISO-8859-1.'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2305 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2306 | # to file | ||||||||||||||||||||||||||||||||||||||||||||||
| 2307 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2308 | # "Hello, world! This is ISO-8859-1." | ||||||||||||||||||||||||||||||||||||||||||||||
| 2309 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2310 | # bless(..., "Venus::Os") | ||||||||||||||||||||||||||||||||||||||||||||||
| 2311 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2312 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2313 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2314 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2315 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2316 | =item write example 9 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2317 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2318 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2319 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2320 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2321 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2322 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 2323 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2324 | use IO::File; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2325 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2326 | my $fh = IO::File->new('t/data/texts/iso-8859-1.txt', 'w'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2327 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2328 | my $write = $os->write($fh, 'Hello, world! This is ISO-8859-1.'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2329 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2330 | # to ISO-8859-1 encoded file | ||||||||||||||||||||||||||||||||||||||||||||||
| 2331 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2332 | # "Hello, world! This is ISO-8859-1." | ||||||||||||||||||||||||||||||||||||||||||||||
| 2333 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2334 | # bless(..., "Venus::Os") | ||||||||||||||||||||||||||||||||||||||||||||||
| 2335 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2336 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2337 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2338 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2339 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2340 | =item write example 10 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2341 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2342 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2343 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2344 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2345 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2346 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 2347 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2348 | my $file = 't/data/texts/utf-16be.txt'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2349 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2350 | my $write = $os->write($file, 'Hello, world! こんにちは世界!', 'UTF-16BE'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2351 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2352 | # to UTF-16BE encoded file | ||||||||||||||||||||||||||||||||||||||||||||||
| 2353 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2354 | # "Hello, world! こんにちは世界!" | ||||||||||||||||||||||||||||||||||||||||||||||
| 2355 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2356 | # bless(..., "Venus::Os") | ||||||||||||||||||||||||||||||||||||||||||||||
| 2357 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2358 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2359 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2360 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2361 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2362 | =item write example 11 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2363 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2364 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2365 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2366 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2367 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2368 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 2369 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2370 | my $file = 't/data/texts/utf-16le.txt'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2371 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2372 | my $write = $os->write($file, 'Hello, world! こんにちは世界!', 'UTF-16LE'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2373 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2374 | # to UTF-16LE encoded file | ||||||||||||||||||||||||||||||||||||||||||||||
| 2375 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2376 | # "Hello, world! こんにちは世界!" | ||||||||||||||||||||||||||||||||||||||||||||||
| 2377 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2378 | # bless(..., "Venus::Os") | ||||||||||||||||||||||||||||||||||||||||||||||
| 2379 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2380 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2381 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2382 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2383 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2384 | =item write example 12 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2385 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2386 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2387 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2388 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2389 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2390 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 2391 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2392 | my $file = 't/data/texts/utf-32be.txt'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2393 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2394 | my $write = $os->write($file, 'Hello, world! こんにちは世界!', 'UTF-32BE'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2395 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2396 | # to UTF-32BE encoded file | ||||||||||||||||||||||||||||||||||||||||||||||
| 2397 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2398 | # "Hello, world! こんにちは世界!" | ||||||||||||||||||||||||||||||||||||||||||||||
| 2399 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2400 | # bless(..., "Venus::Os") | ||||||||||||||||||||||||||||||||||||||||||||||
| 2401 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2402 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2403 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2404 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2405 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2406 | =item write example 13 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2407 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2408 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2409 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2410 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2411 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2412 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 2413 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2414 | my $file = 't/data/texts/utf-32le.txt'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2415 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2416 | my $write = $os->write($file, 'Hello, world! こんにちは世界!', 'UTF-32LE'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2417 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2418 | # to UTF-32LE encoded file | ||||||||||||||||||||||||||||||||||||||||||||||
| 2419 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2420 | # "Hello, world! こんにちは世界!" | ||||||||||||||||||||||||||||||||||||||||||||||
| 2421 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2422 | # bless(..., "Venus::Os") | ||||||||||||||||||||||||||||||||||||||||||||||
| 2423 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2424 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2425 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2426 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2427 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2428 | =item write example 14 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2429 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2430 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 2431 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2432 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2433 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2434 | # on linux | ||||||||||||||||||||||||||||||||||||||||||||||
| 2435 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2436 | my $file = 't/data/texts/utf-8.txt'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2437 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2438 | my $write = $os->write($file, 'Hello, world! こんにちは世界!', 'UTF-8'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2439 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2440 | # to UTF-8 encoded file | ||||||||||||||||||||||||||||||||||||||||||||||
| 2441 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2442 | # "Hello, world! こんにちは世界!" | ||||||||||||||||||||||||||||||||||||||||||||||
| 2443 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2444 | # bless(..., "Venus::Os") | ||||||||||||||||||||||||||||||||||||||||||||||
| 2445 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2446 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2447 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2448 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 2449 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2450 | =item B<may raise> L<Venus::Os::Error> C<on.write.open.file> | ||||||||||||||||||||||||||||||||||||||||||||||
| 2451 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2452 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2453 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2454 | $os->write('/path/to/nowhere/file.txt', 'content'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 2455 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2456 | # Error! (on.write.open.file) | ||||||||||||||||||||||||||||||||||||||||||||||
| 2457 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2458 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 2459 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2460 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 2461 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2462 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||||||||
| 2463 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2464 | Awncorp, C<awncorp@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||
| 2465 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2466 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 2467 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2468 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||
| 2469 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2470 | Copyright (C) 2022, Awncorp, C<awncorp@cpan.org>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2471 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2472 | This program is free software, you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||
| 2473 | the terms of the Apache license version 2.0. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2474 | |||||||||||||||||||||||||||||||||||||||||||||||
| 2475 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||