Strip/Util.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 56 CC 2 SCAR 11.0
CC
2
Cov
0%
hexdump
6.0
true
2.0
false
2.0
CRAP 3.0
1 package Palm::Zetetic::Strip::Util;
2  
3 use strict;
4  
5 use vars qw(@ISA @EXPORT_OK $VERSION);
6  
7 require Exporter;
8  
9 @ISA = qw(Exporter);
10 @EXPORT_OK = qw(hexdump null_split true false);
11 $VERSION = "1.02";
12  
13 sub true
14 {
15 return 1;
16 }
17  
18 sub false
19 {
20 return 0;
21 }
22  
23 # hexdump was ripped off from the p5-Palm CPAN package in the
24 # "pdbdump" script.
25  
26 sub hexdump
27 {
28 my $prefix = shift; # What to print in front of each line
29 my $data = shift; # The data to dump
30 my $maxlines = shift; # Max # of lines to dump
31 my $offset; # Offset of current chunk
32  
33 for ($offset = 0; $offset < length($data); $offset += 16)
34 {
35 my $hex; # Hex values of the data
36 my $ascii; # ASCII values of the data
37 my $chunk; # Current chunk of data
38  
39 last if defined($maxlines) && ($offset >= ($maxlines * 16));
40  
41 $chunk = substr($data, $offset, 16);
42  
43 ($hex = $chunk) =~ s/./sprintf "%02x ", ord($&)/ges;
44  
45 ($ascii = $chunk) =~ y/\040-\176/./c;
46  
47 printf "%s %-48s|%-16s|\n", $prefix, $hex, $ascii;
48 }
49 }
50  
51 sub null_split
52 {
53 my ($string) = @_;
54 my @strings;
55  
56 @strings = ();
57 while (length($string) > 0)
58 {
59 my $x = unpack("Z*", $string);
60 push(@strings, $x);
61 $string = substr($string, length($x)+1);
62 }
63  
64 return @strings;
65 }