| 1 | =head1 NAME | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | util - optex utility modules | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | optex -Mutil | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | This module sample utility functions for command B<optex>. | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | Function can be called with option declaration. Parameters for the | ||||||||||||||||||||||||||||
| 14 | function are passed by name and value list: I<name>=I<value>. Value 1 | ||||||||||||||||||||||||||||
| 15 | is assigned for the name without value. | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | In this example, | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | optex -Mutil::function(debug,message=hello,count=3) | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | option I<debug> has value 1, I<message> has string "hello", and | ||||||||||||||||||||||||||||
| 22 | I<count> also has string "3". | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =head1 FUNCTION | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =cut | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | package App::optex::util; | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 2 | ▶ | use List::Util qw(pairmap); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | =pod | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | =over 7 | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | =item B<setenv>(I<NAME>=VALUE,I<NAME2>=VALUE2,...) | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | Set environment variable I<NAME> to I<VALUE>, and so on. | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | =back | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | =cut | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub setenv { | ||||||||||||||||||||||||||
|
Subroutine
setenv: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | pairmap { $ENV{$a} = $b } @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =pod | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | =over 7 | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =item B<chdir>(B<PATH>=I<directory>) | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | Change working directory to I<directory>. | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =back | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =cut | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | ▶ | sub chdir { | ||||||||||||||||||||||||||
|
Subroutine
chdir: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 64 | 0 | my %arg = @_; | |||||||||||||||||||||||||||
| 65 | 0 | ▶ | my $dir = ($arg{PATH} || $arg{path}) or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$arg{'PATH'} || $arg{'path'}
MC/DC0%0/2
$arg{'PATH'} || $arg{'path'}
$arg{'PATH'}
$arg{'path'}
Truth table0%0/3
A || B
A= $arg{'PATH'}B= $arg{'path'}
| |||||||||||||||||||||||||||||
| 66 | 0 | warn __PACKAGE__."::chdir PATH is required.\n"; | |||||||||||||||||||||||||||
| 67 | 0 | return; | |||||||||||||||||||||||||||
| 68 | }; | ||||||||||||||||||||||||||||
| 69 | 0 | ▶ | chdir $dir or warn "$dir: $!\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 2 | 1; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | __DATA__ | ||||||||||||||||||||||||||||