| 1 | package Archive::Lha::Stream::Hex; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use base qw( Archive::Lha::Stream::Base ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | sub open { | ||||||||
|
Subroutine
open: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 9 | 1 | my ($self, %options) = @_; | |||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | croak "Array reference of hex strings is missing" unless ref $options{hex} eq 'ARRAY'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 12 | |||||||||||
| 13 | 1 | my @array = map { pack 'H2', $_ } @{ $options{hex} }; | |||||||||
| 14 | |||||||||||
| 15 | 1 | $self->{array} = \@array; | |||||||||
| 16 | 1 | $self->{length} = scalar @array; | |||||||||
| 17 | 1 | $self->{pos} = 0; | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 5 | ▶ | sub read { | ||||||||
|
Subroutine
read: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 21 | 5 | my ($self, $length) = @_; | |||||||||
| 22 | |||||||||||
| 23 | 5 | my $from = $self->{pos}; | |||||||||
| 24 | 5 | my $to = $self->{pos} + $length - 1; | |||||||||
| 25 | 5 | ▶ | $to = $self->{length} - 1 if $to >= $self->{length}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 5 | my $str = join '', @{ $self->{array} }[$from .. $to]; | |||||||||
| 27 | 5 | $self->{pos} = $to + 1; | |||||||||
| 28 | 5 | return $str; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 2 | 1; | |||||||||
| 32 | |||||||||||
| 33 | __END__ | ||||||||||