| 1 | package Data::All::Format::Fixed; | ||||||||||
| 2 | |||||||||||
| 3 | |||||||||||
| 4 | # $Id: Fixed.pm,v 1.1.1.1 2005/05/10 23:56:20 dmandelbaum Exp $ | ||||||||||
| 5 | |||||||||||
| 6 | |||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use Data::All::Format::Base; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | use vars qw(@EXPORT $VERSION); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 1 | @EXPORT = qw(); | |||||||||
| 16 | 1 | $VERSION = 0.11; | |||||||||
| 17 | |||||||||||
| 18 | 1 | ▶ | use base 'Exporter'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 1 | our @EXPORT = qw(new internal attribute populate error init); | |||||||||
| 20 | |||||||||||
| 21 | 1 | attribute 'lengths' => []; | |||||||||
| 22 | 1 | attribute 'break' => "\n"; # currently useless b/c it's hardcoded below | |||||||||
| 23 | |||||||||||
| 24 | 1 | attribute 'type'; | |||||||||
| 25 | |||||||||||
| 26 | sub expand($); | ||||||||||
| 27 | sub contract(\@); | ||||||||||
| 28 | |||||||||||
| 29 | |||||||||||
| 30 | # TODO: Forward look to defined lengths if they are blank | ||||||||||
| 31 | |||||||||||
| 32 | sub expand($) | ||||||||||
| 33 | 0 | ▶ | { | ||||||||
|
Subroutine
expand: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 34 | 0 | my $self = shift; | |||||||||
| 35 | 0 | my $record = shift; | |||||||||
| 36 | 0 | my $template = $self->pack_template(); | |||||||||
| 37 | |||||||||||
| 38 | 0 | return unpack($template, $record); | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | sub contract(\@) | ||||||||||
| 42 | 3 | ▶ | { | ||||||||
|
Subroutine
contract: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 43 | 3 | my $self = shift; | |||||||||
| 44 | 3 | my $values = shift; | |||||||||
| 45 | 3 | my $template = $self->pack_template(); | |||||||||
| 46 | |||||||||||
| 47 | # NOTE: Line break is hardcoded to \n | ||||||||||
| 48 | 3 | return pack($template, @{ $values })."\n"; | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | |||||||||||
| 52 | sub pack_template() | ||||||||||
| 53 | 3 | ▶ | { | ||||||||
|
Subroutine
pack_template: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 54 | 3 | my $self = shift; | |||||||||
| 55 | 3 | my @template; | |||||||||
| 56 | |||||||||||
| 57 | 3 | foreach my $e (@{ $self->lengths }) | |||||||||
| 58 | { | ||||||||||
| 59 | 12 | push(@template, "A$e"); | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | 3 | ▶ | return !wantarray ? join(' ', @template) : @template; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | |||||||||||
| 66 | |||||||||||
| 67 | |||||||||||
| 68 | 1 | 1; | |||||||||