Simple/Util.pm

filter: Statementstmt 78.5% 121 / 154 Branchbran 63.2% 62 / 98 Conditioncond 51.7% 15 / 29 MC/DCmcdc 22.2% 4 / 18 Subroutinesub 94.4% 17 / 18 Podpod 0.0% 0 / 13 totaltotal 66.3% 219 / 330 CC 64 SCAR 26.5
CC
64
Cov
70%
utf8_chr
56.0
os
22.5
unescapeHTML
17.6
CRAP 14.1
« Simple.pm ↑ Summary Simple/Cookie.pm »
1 package CGI::Simple::Util;
2 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 20 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 20 ▶use vars qw( $VERSION @EXPORT_OK @ISA $UTIL );
Subroutine BEGIN: called CC=1 SCAR=0.0
5 20 $VERSION = '1.27';
6 20 require Exporter;
7 20 @ISA = qw( Exporter );
8 20 @EXPORT_OK = qw(
9 rearrange make_attributes expires
10 escapeHTML unescapeHTML escape unescape
11 );
12  
13 sub rearrange {
14 137 ▶ my ( $order, @params ) = @_;
Subroutine rearrange: called CC=10 SCAR=23.1
Pod undocumented
15 137 my ( %pos, @result, %leftover );
16 137 ▶ return () unless @params;
Branch: 1 branch
BranchTrueFalseTotal
unless @params 17 120 137
17 120 ▶ if ( ref $params[0] eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $params[0] eq 'HASH') { } 0 120 120
18 0 @params = %{ $params[0] };
19 }
20 else {
21 120 ▶ return @params unless $params[0] =~ m/^-/;
Branch: 1 branch
BranchTrueFalseTotal
unless $params[0] =~ /^-/ 11 109 120
22 }
23  
24 # map parameters into positional indices
25 109 my $i = 0;
26 109 for ( @$order ) {
27 839 ▶ for ( ref( $_ ) eq 'ARRAY' ? @$_ : $_ ) { $pos{ lc( $_ ) } = $i; }
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 164 675 839
28 839 $i++;
29 }
30 109 $#result = $#$order; # preextend
31 109 ▶ while ( @params ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@params) 304 109 413
32 304 my $key = lc( shift( @params ) );
33 304 $key =~ s/^\-//;
34 304 ▶ if ( exists $pos{$key} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $pos{$key}) { } 291 13 304
35 291 $result[ $pos{$key} ] = shift( @params );
36 }
37 else {
38 13 $leftover{$key} = shift( @params );
39 }
40 }
41 109 ▶ push @result, make_attributes( \%leftover, 1 ) if %leftover;
Branch: 1 branch
BranchTrueFalseTotal
if %leftover 12 97 109
42 109 return @result;
43 }
44  
45 sub make_attributes {
46 12 ▶ my $attref = shift;
Subroutine make_attributes: called CC=7 SCAR=20.6
Pod undocumented
47 12 ▶ my $escape = shift || 0;
Condition50%1/2
shift() || 0
l!l
120
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
48 12 ▶ return () unless $attref && ref $attref eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless $attref and ref $attref eq "HASH" 0 12 12
Condition33%1/3
$attref and ref $attref eq "HASH"
!ll&&!rl&&r
0012
MC/DC0%0/2
$attref and ref $attref eq "HASH"
$attref ref $attref eq "HASH"
Truth table33%1/3
A and B
A= $attrefB= ref $attref eq "HASH"
ABresult
0X0
100
111
49 12 my @attrib;
50 12 for my $key ( keys %{$attref} ) {
51 13 ( my $mod_key = $key ) =~ s/^-//; # get rid of initial - if present
52 13 $mod_key = lc $mod_key; # parameters are lower case
53 13 $mod_key =~ tr/_/-/; # use dashes
54 my $value
55 13 ▶ = $escape ? escapeHTML( $attref->{$key} ) : $attref->{$key};
Branch: 1 branch
BranchTrueFalseTotal
$escape ? : 13 0 13
56 13 ▶ push @attrib, defined $value ? qq/$mod_key="$value"/ : $mod_key;
Branch: 1 branch
BranchTrueFalseTotal
defined $value ? : 13 0 13
57 }
58 12 return @attrib;
59 }
60  
61 # This internal routine creates date strings suitable for use in
62 # cookies and HTTP headers. (They differ, unfortunately.)
63 # Thanks to Mark Fisher for this.
64 sub expires {
65 26 ▶ my ( $time, $format ) = @_;
Subroutine expires: called CC=4 SCAR=13.9
Pod undocumented
66 26 ▶ $format ||= 'http';
Condition50%1/2
$format ||= "http"
l!l
260
MC/DC0%0/1
$format ||= "http"
$format
Truth table50%1/2
A
A= $format
Aresult
11
00
67 26 my @MON = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
68 26 my @WDAY = qw( Sun Mon Tue Wed Thu Fri Sat );
69  
70 # pass through preformatted dates for the sake of expire_calc()
71 26 $time = _expire_calc( $time );
72 26 ▶ return $time unless $time =~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $time =~ /^\d+$/ 6 20 26
73  
74 # make HTTP/cookie date string from GMT'ed time
75 # (cookies use '-' as date separator, HTTP uses ' ')
76 20 ▶ my $sc = $format eq 'cookie' ? '-' : ' ';
Branch: 1 branch
BranchTrueFalseTotal
$format eq 'cookie' ? : 7 13 20
77 20 my ( $sec, $min, $hour, $mday, $mon, $year, $wday ) = gmtime( $time );
78 20 $year += 1900;
79 20 return sprintf( "%s, %02d$sc%s$sc%04d %02d:%02d:%02d GMT",
80 $WDAY[$wday], $mday, $MON[$mon], $year, $hour, $min, $sec );
81 }
82  
83 # This internal routine creates an expires time exactly some number of
84 # hours from the current time. It incorporates modifications from Mark Fisher.
85 # format for time can be in any of the forms...
86 # "now" -- expire immediately
87 # "+180s" -- in 180 seconds
88 # "+2m" -- in 2 minutes
89 # "+12h" -- in 12 hours
90 # "+1d" -- in 1 day
91 # "+3M" -- in 3 months
92 # "+2y" -- in 2 years
93 # "-3m" -- 3 minutes ago(!)
94 # If you don't supply one of these forms, we assume you are specifying
95 # the date yourself
96 sub _expire_calc {
97 31 ▶ my ( $time ) = @_;
Subroutine _expire_calc: called CC=6 SCAR=17.9
98 31 my %mult = (
99 's' => 1,
100 'm' => 60,
101 'h' => 60 * 60,
102 'd' => 60 * 60 * 24,
103 'M' => 60 * 60 * 24 * 30,
104 'y' => 60 * 60 * 24 * 365
105 );
106 31 my $offset;
107 31 ▶ if ( !$time or lc $time eq 'now' ) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $time or lc $time eq 'now') { } 15 16 31
elsif ($time =~ /^\d+/) { } 1 15 16
elsif ($time =~ /^([+-]?(?:\d+|\d*\.\d*))([mhdMy]?)/) { } 9 6 15
Condition100%3/3
not $time or lc $time eq "now"
l!l&&r!l&&!r
10516
MC/DC100%2/2
not $time or lc $time eq "now"
not $time lc $time eq "now"
Truth table100%3/3
not(A) or B
A= not $timeB= lc $time eq "now"
ABresult
1X1
011
000
108 15 $offset = 0;
109 }
110 elsif ( $time =~ /^\d+/ ) {
111 1 return $time;
112 }
113 elsif ( $time =~ /^([+-]?(?:\d+|\d*\.\d*))([mhdMy]?)/ ) {
114 9 ▶ $offset = ( $mult{$2} || 1 ) * $1;
Condition50%1/2
$mult{$2} || 1
l!l
90
MC/DC0%0/1
$mult{$2} || 1
$mult{$2}
Truth table50%1/2
A
A= $mult{$2}
Aresult
11
00
115 }
116 else {
117 6 return $time;
118 }
119 24 my $cur_time = time;
120 24 return ( $cur_time + $offset );
121 }
122  
123 sub escapeHTML {
124 21 ▶ my ( $escape, $text ) = @_;
Subroutine escapeHTML: called CC=3 SCAR=11.9
Pod undocumented
125 21 ▶ return undef unless defined $escape;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $escape 1 20 21
126 20 $escape =~ s/&/&/g;
127 20 $escape =~ s/"/"/g;
128 20 $escape =~ s/</&lt;/g;
129 20 $escape =~ s/>/&gt;/g;
130  
131 # these next optional escapes make text look the same when rendered in HTML
132 20 ▶ if ( $text ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($text) 0 20 20
133 0 $escape =~ s/\t/ /g; # tabs to 4 spaces
134 0 $escape =~ s/( {2,})/"&nbsp;" x length $1/eg; # whitespace escapes
135 0 $escape =~ s/\n/<br>\n/g; # newlines to <br>
136 }
137 20 return $escape;
138 }
139  
140 sub unescapeHTML {
141 52 ▶ my ( $unescape ) = @_;
Subroutine unescapeHTML: called CC=14 SCAR=28.7
Pod undocumented
142 52 ▶ return undef unless defined( $unescape );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $unescape 5 47 52
143 47 my $latin = $UTIL->{'charset'} =~ /^(?:ISO-8859-1|WINDOWS-1252)$/i;
144 47 my $ebcdic = $UTIL->{'ebcdic'};
145  
146 # credit to Randal Schwartz for original version of this
147 47 $unescape =~ s[&(.*?);]{
148 13 local $_ = $1;
149 /^amp$/i ? "&" :
150 /^quot$/i ? '"' :
151 /^gt$/i ? ">" :
152 /^lt$/i ? "<" :
153 /^#(\d+)$/ && $latin ? chr($1) :
154 /^#(\d+)$/ && $ebcdic ? chr($UTIL->{'a2e'}->[$1]) :
155 /^#x([0-9a-f]+)$/i && $latin ? chr(hex($1)) :
156 13 ▶ /^#x([0-9a-f]+)$/i && $ebcdic ? chr($UTIL->{'a2e'}->[hex $1]) :
Branch: 8 branches
BranchTrueFalseTotal
/^amp$/i ? : 2 11 13
/^quot$/i ? : 2 9 11
/^gt$/i ? : 2 7 9
/^lt$/i ? : 2 5 7
/^#(\d+)$/ && $latin ? : 4 1 5
/^#(\d+)$/ && $ebcdic ? : 0 1 1
/^#x([0-9a-f]+)$/i && $latin ? : 0 1 1
/^#x([0-9a-f]+)$/i && $ebcdic ? : 0 1 1
Condition41%5/12
/^#(\d+)$/ and $latin
!ll&&!rl&&r
104
/^#(\d+)$/ and $ebcdic
!ll&&!rl&&r
100
/^#x([0-9a-f]+)$/i and $latin
!ll&&!rl&&r
100
/^#x([0-9a-f]+)$/i and $ebcdic
!ll&&!rl&&r
100
MC/DC50%1/2
/^#(\d+)$/ and $latin
/^#(\d+)$/ $latin
MC/DC0%0/2
/^#(\d+)$/ and $ebcdic
/^#(\d+)$/ $ebcdic
MC/DC0%0/2
/^#x([0-9a-f]+)$/i and $latin
/^#x([0-9a-f]+)$/i $latin
MC/DC0%0/2
/^#x([0-9a-f]+)$/i and $ebcdic
/^#x([0-9a-f]+)$/i $ebcdic
Truth table66%2/3
A and B
A= /^#(\d+)$/B= $latin
ABresult
0X0
100
111
Truth table33%1/3
A and B
A= /^#(\d+)$/B= $ebcdic
ABresult
0X0
100
111
Truth table33%1/3
A and B
A= /^#x([0-9a-f]+)$/iB= $latin
ABresult
0X0
100
111
Truth table33%1/3
A and B
A= /^#x([0-9a-f]+)$/iB= $ebcdic
ABresult
0X0
100
111
157 "\&$_;"
158 }gex;
159 47 return $unescape;
160 }
161  
162 # URL-encode data
163 sub escape {
164 191 ▶ my ( $toencode ) = @_;
Subroutine escape: called CC=3 SCAR=12.0
Pod undocumented
165 191 ▶ return undef unless defined $toencode;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $toencode 0 191 191
166 191 ▶ if ( $UTIL->{'ebcdic'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::Simple::Util::UTIL->{'ebcdic'}) { } 0 191 191
167 0 $toencode
168 0 =~ s/([^a-zA-Z0-9_.-])/uc sprintf "%%%02x", $UTIL->{'e2a'}->[ord $1]/eg;
169 }
170 else {
171 191 $toencode =~ s/([^a-zA-Z0-9_.-])/uc sprintf "%%%02x", ord $1 /eg;
172 }
173 191 return $toencode;
174 }
175  
176 # unescape URL-encoded data
177 sub unescape {
178 111 ▶ my ( $todecode ) = @_;
Subroutine unescape: called CC=4 SCAR=15.2
Pod undocumented
179 111 ▶ return undef unless defined $todecode;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $todecode 0 111 111
180 111 $todecode =~ tr/+/ /;
181 111 ▶ if ( $UTIL->{'ebcdic'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::Simple::Util::UTIL->{'ebcdic'}) { } 0 111 111
182 0 $todecode =~ s/%([0-9a-fA-F]{2})/chr $UTIL->{'a2e'}->[hex $1]/ge;
183 }
184 else {
185 111 $todecode =~ s/%(?:([0-9a-fA-F]{2})|u([0-9a-fA-F]{4}))/
186 40 ▶ defined($1)? chr hex($1) : utf8_chr(hex($2))/ge;
Branch: 1 branch
BranchTrueFalseTotal
defined $1 ? : 40 0 40
187 }
188 111 return $todecode;
189 }
190  
191 sub utf8_chr ($) {
192 0 ▶ my $c = shift;
Subroutine utf8_chr: not called CC=7 SCAR=40.3
Pod undocumented
193 0 ▶ if ( $c < 0x80 ) {
Branch: 6 branches
BranchTrueFalseTotal
if ($c < 128) { } 0 0 0
elsif ($c < 2048) { } 0 0 0
elsif ($c < 65536) { } 0 0 0
elsif ($c < 2097152) { } 0 0 0
elsif ($c < 67108864) { } 0 0 0
elsif ($c < 2147483648) { } 0 0 0
194 0 return sprintf( "%c", $c );
195 }
196 elsif ( $c < 0x800 ) {
197 0 return sprintf( "%c%c", 0xc0 | ( $c >> 6 ), 0x80 | ( $c & 0x3f ) );
198 }
199 elsif ( $c < 0x10000 ) {
200 0 return sprintf( "%c%c%c",
201 0xe0 | ( $c >> 12 ),
202 0x80 | ( ( $c >> 6 ) & 0x3f ),
203 0x80 | ( $c & 0x3f ) );
204 }
205 elsif ( $c < 0x200000 ) {
206 0 return sprintf( "%c%c%c%c",
207 0xf0 | ( $c >> 18 ),
208 0x80 | ( ( $c >> 12 ) & 0x3f ),
209 0x80 | ( ( $c >> 6 ) & 0x3f ),
210 0x80 | ( $c & 0x3f ) );
211 }
212 elsif ( $c < 0x4000000 ) {
213 0 return sprintf( "%c%c%c%c%c",
214 0xf8 | ( $c >> 24 ),
215 0x80 | ( ( $c >> 18 ) & 0x3f ),
216 0x80 | ( ( $c >> 12 ) & 0x3f ),
217 0x80 | ( ( $c >> 6 ) & 0x3f ),
218 0x80 | ( $c & 0x3f ) );
219  
220 }
221 elsif ( $c < 0x80000000 ) {
222 0 return sprintf(
223 "%c%c%c%c%c%c",
224 0xfc | ( $c >> 30 ), # was 0xfe patch Thomas L. Shinnick
225 0x80 | ( ( $c >> 24 ) & 0x3f ),
226 0x80 | ( ( $c >> 18 ) & 0x3f ),
227 0x80 | ( ( $c >> 12 ) & 0x3f ),
228 0x80 | ( ( $c >> 6 ) & 0x3f ),
229 0x80 | ( $c & 0x3f )
230 );
231 }
232 else {
233 0 return utf8( 0xfffd );
234 }
235 }
236  
237 # We need to define a number of things about the operating environment so
238 # we do this on first initialization and store the results in in an object
239 BEGIN {
240  
241 20 ▶ $UTIL = CGI::Simple::Util->new; # initialize our $UTIL object
Subroutine BEGIN: called CC=1 SCAR=0.0
242  
243 sub new {
244 20 ▶ my $class = shift;
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
245 20 ▶ $class = ref( $class ) || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
0200
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
246 20 my $self = {};
247 20 bless $self, $class;
248 20 $self->init;
249 20 return $self;
250 }
251  
252 sub init {
253 20 ▶ my $self = shift;
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
254 20 $self->charset;
255 20 $self->os;
256 20 $self->ebcdic;
257 }
258  
259 sub charset {
260 42 ▶ my ( $self, $charset ) = @_;
Subroutine charset: called CC=3 SCAR=11.0
Pod undocumented
261 42 ▶ $self->{'charset'} = $charset if $charset;
Branch: 1 branch
BranchTrueFalseTotal
if $charset 2 40 42
262 42 ▶ $self->{'charset'}
Condition100%2/2
$self->{"charset"} ||= "ISO-8859-1"
l!l
2220
MC/DC100%1/1
$self->{"charset"} ||= "ISO-8859-1"
$self->{"charset"}
Truth table100%2/2
A
A= $self->{"charset"}
Aresult
11
00
263 ||= 'ISO-8859-1'; # set to the safe ISO-8859-1 if not defined
264 42 return $self->{'charset'};
265 }
266  
267 sub os {
268 20 ▶ my ( $self, $OS ) = @_;
Subroutine os: called CC=10 SCAR=31.1
Pod undocumented
269 20 ▶ $self->{'os'} = $OS if $OS; # allow value to be set manually
Branch: 1 branch
BranchTrueFalseTotal
if $OS 0 20 20
270 20 $OS = $self->{'os'};
271 20 ▶ unless ( $OS ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($OS) 20 0 20
272 20 ▶ unless ( $OS = $^O ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($OS = $^O) 0 20 20
273 0 require Config;
274 0 $OS = $Config::Config{'osname'};
275 }
276 20 ▶ if ( $OS =~ /Win/i ) {
Branch: 6 branches
BranchTrueFalseTotal
if ($OS =~ /Win/i) { } 0 20 20
elsif ($OS =~ /vms/i) { } 0 20 20
elsif ($OS =~ /bsdos/i) { } 0 20 20
elsif ($OS =~ /dos/i) { } 0 20 20
elsif ($OS =~ /^MacOS$/i) { } 0 20 20
elsif ($OS =~ /os2/i) { } 0 20 20
277 0 $OS = 'WINDOWS';
278 }
279 elsif ( $OS =~ /vms/i ) {
280 0 $OS = 'VMS';
281 }
282 elsif ( $OS =~ /bsdos/i ) {
283 0 $OS = 'UNIX';
284 }
285 elsif ( $OS =~ /dos/i ) {
286 0 $OS = 'DOS';
287 }
288 elsif ( $OS =~ /^MacOS$/i ) {
289 0 $OS = 'MACINTOSH';
290 }
291 elsif ( $OS =~ /os2/i ) {
292 0 $OS = 'OS2';
293 }
294 else {
295 20 $OS = 'UNIX';
296 }
297 }
298 20 return $self->{'os'} = $OS;
299 }
300  
301 sub ebcdic {
302 20 ▶ my $self = shift;
Subroutine ebcdic: called CC=3 SCAR=15.4
Pod undocumented
303 20 ▶ return $self->{'ebcdic'} if exists $self->{'ebcdic'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"ebcdic"} 0 20 20
304 20 $self->{'ebcdic'} = "\t" ne "\011" ? 1 : 0;
305 20 ▶ if ( $self->{'ebcdic'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ebcdic"}) 0 20 20
306  
307 # (ord('^') == 95) for codepage 1047 as on os390, vmesa
308 0 my @A2E = (
309 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 21, 11,
310 12, 13, 14, 15, 16, 17, 18, 19, 60, 61, 50, 38,
311 24, 25, 63, 39, 28, 29, 30, 31, 64, 90, 127, 123,
312 91, 108, 80, 125, 77, 93, 92, 78, 107, 96, 75, 97,
313 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 122, 94,
314 76, 126, 110, 111, 124, 193, 194, 195, 196, 197, 198, 199,
315 200, 201, 209, 210, 211, 212, 213, 214, 215, 216, 217, 226,
316 227, 228, 229, 230, 231, 232, 233, 173, 224, 189, 95, 109,
317 121, 129, 130, 131, 132, 133, 134, 135, 136, 137, 145, 146,
318 147, 148, 149, 150, 151, 152, 153, 162, 163, 164, 165, 166,
319 167, 168, 169, 192, 79, 208, 161, 7, 32, 33, 34, 35,
320 36, 37, 6, 23, 40, 41, 42, 43, 44, 9, 10, 27,
321 48, 49, 26, 51, 52, 53, 54, 8, 56, 57, 58, 59,
322 4, 20, 62, 255, 65, 170, 74, 177, 159, 178, 106, 181,
323 187, 180, 154, 138, 176, 202, 175, 188, 144, 143, 234, 250,
324 190, 160, 182, 179, 157, 218, 155, 139, 183, 184, 185, 171,
325 100, 101, 98, 102, 99, 103, 158, 104, 116, 113, 114, 115,
326 120, 117, 118, 119, 172, 105, 237, 238, 235, 239, 236, 191,
327 128, 253, 254, 251, 252, 186, 174, 89, 68, 69, 66, 70,
328 67, 71, 156, 72, 84, 81, 82, 83, 88, 85, 86, 87,
329 140, 73, 205, 206, 203, 207, 204, 225, 112, 221, 222, 219,
330 220, 141, 142, 223
331 );
332 0 my @E2A = (
333 0, 1, 2, 3, 156, 9, 134, 127, 151, 141, 142, 11,
334 12, 13, 14, 15, 16, 17, 18, 19, 157, 10, 8, 135,
335 24, 25, 146, 143, 28, 29, 30, 31, 128, 129, 130, 131,
336 132, 133, 23, 27, 136, 137, 138, 139, 140, 5, 6, 7,
337 144, 145, 22, 147, 148, 149, 150, 4, 152, 153, 154, 155,
338 20, 21, 158, 26, 32, 160, 226, 228, 224, 225, 227, 229,
339 231, 241, 162, 46, 60, 40, 43, 124, 38, 233, 234, 235,
340 232, 237, 238, 239, 236, 223, 33, 36, 42, 41, 59, 94,
341 45, 47, 194, 196, 192, 193, 195, 197, 199, 209, 166, 44,
342 37, 95, 62, 63, 248, 201, 202, 203, 200, 205, 206, 207,
343 204, 96, 58, 35, 64, 39, 61, 34, 216, 97, 98, 99,
344 100, 101, 102, 103, 104, 105, 171, 187, 240, 253, 254, 177,
345 176, 106, 107, 108, 109, 110, 111, 112, 113, 114, 170, 186,
346 230, 184, 198, 164, 181, 126, 115, 116, 117, 118, 119, 120,
347 121, 122, 161, 191, 208, 91, 222, 174, 172, 163, 165, 183,
348 169, 167, 182, 188, 189, 190, 221, 168, 175, 93, 180, 215,
349 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, 173, 244,
350 246, 242, 243, 245, 125, 74, 75, 76, 77, 78, 79, 80,
351 81, 82, 185, 251, 252, 249, 250, 255, 92, 247, 83, 84,
352 85, 86, 87, 88, 89, 90, 178, 212, 214, 210, 211, 213,
353 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 179, 219,
354 220, 217, 218, 159
355 );
356 0 if ( ord( '^' ) == 106 )
357 { # as in the BS2000 posix-bc coded character set
358 $A2E[91] = 187;
359 $A2E[92] = 188;
360 $A2E[94] = 106;
361 $A2E[96] = 74;
362 $A2E[123] = 251;
363 $A2E[125] = 253;
364 $A2E[126] = 255;
365 $A2E[159] = 95;
366 $A2E[162] = 176;
367 $A2E[166] = 208;
368 $A2E[168] = 121;
369 $A2E[172] = 186;
370 $A2E[175] = 161;
371 $A2E[217] = 224;
372 $A2E[219] = 221;
373 $A2E[221] = 173;
374 $A2E[249] = 192;
375  
376 $E2A[74] = 96;
377 $E2A[95] = 159;
378 $E2A[106] = 94;
379 $E2A[121] = 168;
380 $E2A[161] = 175;
381 $E2A[173] = 221;
382 $E2A[176] = 162;
383 $E2A[186] = 172;
384 $E2A[187] = 91;
385 $E2A[188] = 92;
386 $E2A[192] = 249;
387 $E2A[208] = 166;
388 $E2A[221] = 219;
389 $E2A[224] = 217;
390 $E2A[251] = 123;
391 $E2A[253] = 125;
392 $E2A[255] = 126;
393 }
394 0 elsif ( ord( '^' ) == 176 ) { # as in codepage 037 on os400
395 $A2E[10] = 37;
396 $A2E[91] = 186;
397 $A2E[93] = 187;
398 $A2E[94] = 176;
399 $A2E[133] = 21;
400 $A2E[168] = 189;
401 $A2E[172] = 95;
402 $A2E[221] = 173;
403  
404 $E2A[21] = 133;
405 $E2A[37] = 10;
406 $E2A[95] = 172;
407 $E2A[173] = 221;
408 $E2A[176] = 94;
409 $E2A[186] = 91;
410 $E2A[187] = 93;
411 $E2A[189] = 168;
412 }
413 0 $self->{'a2e'} = \@A2E;
414 0 $self->{'e2a'} = \@E2A;
415 }
416 }
417 }
418  
419 20 1;
420  
421 __END__
« Simple.pm ↑ Summary Simple/Cookie.pm »