All/Format/XML.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 53 CC 2 SCAR 10.6
CC
2
Cov
0%
pack_template
6.0
expand
2.0
contract
2.0
CRAP 2.9
1 package Data::All::Format::XML;
2  
3  
4 # $Id: XML.pm,v 1.1.1.1 2005/05/10 23:56:20 dmandelbaum Exp $
5  
6  
7 use strict;
8 use warnings;
9  
10 use Data::All::Format::Base;
11  
12 use vars qw(@EXPORT $VERSION);
13  
14 @EXPORT = qw();
15 $VERSION = 0.10;
16  
17 use base 'Exporter';
18 our @EXPORT = qw(new internal attribute populate error init _load_format);
19  
20 attribute 'format' => '';
21 attribute 'encoding' => '';
22  
23 attribute 'type';
24  
25 sub expand($);
26 sub contract(\@);
27  
28  
29  
30  
31 sub expand($)
32 {
33 my $self = shift;
34 my $record = shift;
35 my $template = $self->pack_template();
36
37 return unpack($template, $record);
38 }
39  
40 sub contract(\@)
41 {
42 my $self = shift;
43 my $values = shift;
44 my $template = $self->pack_template();
45
46 return pack($template, @{ $values });
47 }
48  
49  
50 sub pack_template()
51 {
52 my $self = shift;
53 my @template;
54
55 foreach my $e (@{ $self->lengths })
56 {
57 push(@template, "A$e");
58 }
59
60 return !wantarray ? join(' ', @template) : @template;
61 }
62  
63  
64  
65  
66  
67  
68  
69  
70 1;