| 1 | package Text::Label::Prepender; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | require Exporter; | |||||||||
| 8 | |||||||||||
| 9 | 1 | our @ISA = qw(Exporter); | |||||||||
| 10 | |||||||||||
| 11 | # Items to export into callers namespace by default. Note: do not export | ||||||||||
| 12 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||
| 13 | # Do not simply export all your public functions/methods/constants. | ||||||||||
| 14 | |||||||||||
| 15 | # This allows declaration use Text::Label::Prepender ':all'; | ||||||||||
| 16 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||||||||||
| 17 | # will save memory. | ||||||||||
| 18 | 1 | our %EXPORT_TAGS = ( 'all' => [ qw( | |||||||||
| 19 | |||||||||||
| 20 | ) ] ); | ||||||||||
| 21 | |||||||||||
| 22 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||
| 23 | |||||||||||
| 24 | 1 | our @EXPORT = qw( | |||||||||
| 25 | |||||||||||
| 26 | ); | ||||||||||
| 27 | 1 | our $VERSION = '1.0'; | |||||||||
| 28 | |||||||||||
| 29 | |||||||||||
| 30 | # Preloaded methods go here. | ||||||||||
| 31 | |||||||||||
| 32 | # | ||||||||||
| 33 | # the object constructor (simplistic version) | ||||||||||
| 34 | # | ||||||||||
| 35 | |||||||||||
| 36 | 1 | my $LABEL = 0; | |||||||||
| 37 | 1 | my $SEP = 1; | |||||||||
| 38 | 1 | my $LABEL_CHAR = 2; | |||||||||
| 39 | 1 | my $LABEL_RE = 3; | |||||||||
| 40 | |||||||||||
| 41 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 42 | |||||||||||
| 43 | 1 | my $pkg = shift; | |||||||||
| 44 | 1 | my %args = @_; | |||||||||
| 45 | 1 | my $self = []; | |||||||||
| 46 | 1 | my $default = { initial_label => '', separator => '', label_char => ':' }; | |||||||||
| 47 | |||||||||||
| 48 | 1 | $self->[$LABEL] = $args{initial_label}; | |||||||||
| 49 | 1 | $self->[$SEP] = $args{separator}; | |||||||||
| 50 | 1 | $self->[$LABEL_CHAR] = $args{label_char}; | |||||||||
| 51 | |||||||||||
| 52 | 1 | my $tmp = $self->[$LABEL_CHAR]; | |||||||||
| 53 | |||||||||||
| 54 | 1 | $self->[$LABEL_RE] = qr/(.*)$tmp\s*$/; | |||||||||
| 55 | |||||||||||
| 56 | 1 | warn $self->[$LABEL_RE]; | |||||||||
| 57 | |||||||||||
| 58 | 1 | bless($self); # but see below (says perldoc perltoot) | |||||||||
| 59 | 1 | return $self; | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | 12 | ▶ | sub process { | ||||||||
|
Subroutine
process: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 63 | |||||||||||
| 64 | 12 | my ($self,$line) = @_; | |||||||||
| 65 | |||||||||||
| 66 | 12 | ▶ | if ($line =~ /$self->[$LABEL_RE]/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | |||||||||||
| 68 | 2 | $self->[$LABEL] = $1; | |||||||||
| 69 | |||||||||||
| 70 | 2 | return undef; | |||||||||
| 71 | |||||||||||
| 72 | } else { | ||||||||||
| 73 | |||||||||||
| 74 | 10 | my @O = | |||||||||
| 75 | |||||||||||
| 76 | return join $self->[$SEP], ($self->[$LABEL], $line); | ||||||||||
| 77 | |||||||||||
| 78 | } | ||||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | |||||||||||
| 82 | 1 | 1; | |||||||||
| 83 | __END__ | ||||||||||