| 1 | package Lang::HL::Export; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | no warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use feature qw(signatures); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | no warnings "experimental::signatures"; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | no warnings "experimental::smartmatch"; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use Hash::Merge; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 1 | require Exporter; | |||||||||
| 12 | |||||||||||
| 13 | 1 | our $VERSION = '0.15'; | |||||||||
| 14 | |||||||||||
| 15 | 1 | our @ISA = qw(Exporter); | |||||||||
| 16 | 1 | our @EXPORT = qw( | |||||||||
| 17 | arrayLength | ||||||||||
| 18 | arrayMerge | ||||||||||
| 19 | arraySort | ||||||||||
| 20 | arrayPop | ||||||||||
| 21 | arrayPush | ||||||||||
| 22 | arrayShift | ||||||||||
| 23 | arrayUnshift | ||||||||||
| 24 | arraySort | ||||||||||
| 25 | arrayJoin | ||||||||||
| 26 | arrayReverse | ||||||||||
| 27 | arrayDelete | ||||||||||
| 28 | hashKeys | ||||||||||
| 29 | hashElement | ||||||||||
| 30 | hashMerge | ||||||||||
| 31 | hashDelete | ||||||||||
| 32 | stringConcat | ||||||||||
| 33 | stringSplit | ||||||||||
| 34 | stringLength | ||||||||||
| 35 | stringPart | ||||||||||
| 36 | stringLast | ||||||||||
| 37 | readFile | ||||||||||
| 38 | writeFile | ||||||||||
| 39 | randomNumber | ||||||||||
| 40 | makeInt | ||||||||||
| 41 | ); | ||||||||||
| 42 | |||||||||||
| 43 | |||||||||||
| 44 | ▶ | sub arrayDelete($array, $element) { | |||||||||
|
Subroutine
arrayDelete: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 45 | 0 | delete($array->[$element]); | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | ▶ | sub hashDelete($hash, $element) { | |||||||||
|
Subroutine
hashDelete: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 49 | 0 | delete($hash->{$element}); | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | ▶ | sub arrayReverse($array) { | |||||||||
|
Subroutine
arrayReverse: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 53 | 0 | my @reversedArray = reverse(@{$array}); | |||||||||
| 54 | 0 | return \@reversedArray; | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | ▶ | sub arrayJoin($separator, $array) { | |||||||||
|
Subroutine
arrayJoin: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 58 | 0 | my @array = @{$array}; | |||||||||
| 59 | 0 | return join($separator, $array); | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | ▶ | sub arraySort($array) { | |||||||||
|
Subroutine
arraySort: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 63 | 0 | my @array = @{$array}; | |||||||||
| 64 | 0 | my @sortedArray = sort(@array); | |||||||||
| 65 | 0 | return \@sortedArray; | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | ▶ | sub arrayUnshift($array, $element) { | |||||||||
|
Subroutine
arrayUnshift: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 69 | 0 | unshift(@{$array}, $element); | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | ▶ | sub arrayShift($array) { | |||||||||
|
Subroutine
arrayShift: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 73 | 0 | return shift(@{$array}); | |||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | ▶ | sub arrayPush($array, $element) { | |||||||||
|
Subroutine
arrayPush: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 77 | 0 | push(@{$array}, $element); | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | ▶ | sub arrayPop($array) { | |||||||||
|
Subroutine
arrayPop: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 81 | 0 | return pop(@{$array}); | |||||||||
| 82 | } | ||||||||||
| 83 | |||||||||||
| 84 | ▶ | sub makeInt($number) { | |||||||||
|
Subroutine
makeInt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 85 | 0 | return int $number; | |||||||||
| 86 | } | ||||||||||
| 87 | |||||||||||
| 88 | ▶ | sub randomNumber($number) { | |||||||||
|
Subroutine
randomNumber: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 89 | 0 | return rand($number); | |||||||||
| 90 | } | ||||||||||
| 91 | |||||||||||
| 92 | ▶ | sub stringConcat($textOne, $textTwo) { | |||||||||
|
Subroutine
stringConcat: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 93 | 0 | return $textOne . $textTwo; | |||||||||
| 94 | } | ||||||||||
| 95 | |||||||||||
| 96 | ▶ | sub stringSplit($separator, $text) { | |||||||||
|
Subroutine
stringSplit: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 97 | 0 | my @split = split($separator, $text); | |||||||||
| 98 | 0 | return \@split; | |||||||||
| 99 | } | ||||||||||
| 100 | |||||||||||
| 101 | ▶ | sub stringLength($text) { | |||||||||
|
Subroutine
stringLength: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 102 | 0 | return length($text); | |||||||||
| 103 | } | ||||||||||
| 104 | |||||||||||
| 105 | ▶ | sub stringPart($text, $from, $to) { | |||||||||
|
Subroutine
stringPart: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 106 | 0 | return substr($text, $from, $to); | |||||||||
| 107 | } | ||||||||||
| 108 | |||||||||||
| 109 | ▶ | sub stringLast($text) { | |||||||||
|
Subroutine
stringLast: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 110 | 0 | return substr($text, -1); | |||||||||
| 111 | } | ||||||||||
| 112 | |||||||||||
| 113 | ▶ | sub arrayLength($array) { | |||||||||
|
Subroutine
arrayLength: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 114 | 0 | my @newArray = @{$array}; | |||||||||
| 115 | 0 | return $#newArray; | |||||||||
| 116 | } | ||||||||||
| 117 | |||||||||||
| 118 | ▶ | sub arrayMerge($arrayOne, $arrayTwo) { | |||||||||
|
Subroutine
arrayMerge: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 119 | 0 | my @newArray = ( @{$arrayOne}, @{$arrayTwo} ); | |||||||||
| 120 | 0 | return \@newArray; | |||||||||
| 121 | } | ||||||||||
| 122 | |||||||||||
| 123 | ▶ | sub hashElement($hash, $element) { | |||||||||
|
Subroutine
hashElement: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 124 | 0 | my %hashMap = %{$hash}; | |||||||||
| 125 | 0 | ▶ | if( exists $hashMap{$element} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 126 | 0 | return 1; | |||||||||
| 127 | } else { | ||||||||||
| 128 | 0 | return 0; | |||||||||
| 129 | } | ||||||||||
| 130 | } | ||||||||||
| 131 | |||||||||||
| 132 | ▶ | sub hashKeys($hash) { | |||||||||
|
Subroutine
hashKeys: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 133 | 0 | my @keys = keys(%{$hash}); | |||||||||
| 134 | 0 | return \@keys; | |||||||||
| 135 | } | ||||||||||
| 136 | |||||||||||
| 137 | ▶ | sub hashMerge($hashOne, $hashTwo) { | |||||||||
|
Subroutine
hashMerge: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 138 | 0 | my $mergedHash = merge($hashOne, $hashTwo); | |||||||||
| 139 | 0 | return $mergedHash; | |||||||||
| 140 | } | ||||||||||
| 141 | |||||||||||
| 142 | ▶ | sub readFile($fileName) { | |||||||||
|
Subroutine
readFile: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 143 | 0 | my $fileContent; | |||||||||
| 144 | 0 | ▶ | open(my $fh, '<:encoding(UTF-8)', $fileName) or die "Cannot open the $fileName file"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 145 | { | ||||||||||
| 146 | 0 | local $/; | |||||||||
| 147 | 0 | $fileContent = <$fh>; | |||||||||
| 148 | } | ||||||||||
| 149 | 0 | close($fh); | |||||||||
| 150 | 0 | return $fileContent; | |||||||||
| 151 | } | ||||||||||
| 152 | |||||||||||
| 153 | ▶ | sub writeFile($fileName, $fileContent) { | |||||||||
|
Subroutine
writeFile: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 154 | 0 | ▶ | open(my $fh, '>:encoding(UTF-8)', $fileName) or die "Cannot open the $fileName file"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 155 | 0 | print $fh $fileContent; | |||||||||
| 156 | 0 | close($fh); | |||||||||
| 157 | } | ||||||||||
| 158 | |||||||||||
| 159 | 1 | 1; | |||||||||
| 160 | __END__ | ||||||||||