Text::Label::Prepender - dynamically prepend label to input strings
use Text::Label::Prepender; my $prepender = Text::Label::Prepender->new ( initial_label => '.', # initial label separator => '/', # output between label and data line label_char => ':', # the character signifying a line is a label ) ;
my @input = qw(aaa bbb ccc one one/hump: ddd eee fff two/hump: ggg hhh iii);
for (@input) {
if (my $processed = $prepender->process($_)) { print $processed, "\n"; }
}
OUTPUT: ./aaa ./bbb ./ccc one/hump/ddd one/hump/eee one/hump/fff two/hump/ggg two/hump/hhh two/hump/iii
This object-oriented package processes input lines, taking a _label_ like:
food/bar:
and prepends the contents of the label line (sans delimiter) to all successive lines, until the next label line comes along. This is the sort of listing that ls -lR would produce.
None by default.
T. M. Brannon, <tbone@cpan.org>
This program is nothing but an OOP-ization of p.224 of "Programming Perl", the edition for Perl 4, which I guess means that Randal Schwartz originally wrote this program.
I thought it would be a nice tool for someone someday and it has been awhile since I wrote anything object-oriented, so what the hay?!
perl.
To install Text::Label::Prepender, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::Label::Prepender
CPAN shell
perl -MCPAN -e shell install Text::Label::Prepender
For more information on module installation, please visit the detailed CPAN module installation guide.