NAME

Launcher::Cascade::ListOfStrings - a wrapper around an array to make it inherit from Launcher::Cascade::Printable

SYNOPSIS

use Launcher::Cascade::ListOfStrings;

my $l = new Launcher::Cascade::ListOfStrings
    -list => [ 'some', 'strings', 'to', 'start', 'with' ],
;

push @$l, 'and', 'then', 'some';

print $l->as_string;
print "$l";   # same as above

# alter the formatting
$l->separator(q{, });
$l->preparator(sub { qq{"$_"} });

print "$l\n"; # prints quoted strings separated by comas

DESCRIPTION

Attributes

preparator

A coderef used to prepare each element in list() before including it the generated string. The coderef will be invoked with $_ locally aliased to the current element. By default, preparator() is the identity function (i.e., it returns $_ untouched).

separator

The string to insert between each element in list() when generating a string (sort of like Perl's $" built-in variable. See perlvar). Defaults to the empty string.

string_after
string_before

Strings to prepend and, respectively, append, to the string representation of the list(). Both default to the empty string.

list

The reference to the array containing the elements. This can also be accessed by dereferencing the object as if it were an array reference (see SYNOPSIS).

Methods

as_string

Returns a string representation of the object. Each element in list() is first passed on to the coderef in preparator(), and the list of results from preparator() is concatenated with the value of separator().

This method is called when the object is "stringified", i.e., when it is interpolated in a double-quoted string.

EXAMPLES

my $l = new Launcher::Cascade::ListOfStrings -list => [ qw( frodo pippin merry sam ) ];

$l->separator(q{, });
$l->preparator(sub { ucfirst });

print "$l\n"; # "Frodo, Pippin, Merry, Sam" and a newline

SEE ALSO

Launcher::Cascade::Printable

AUTHOR

Cédric Bouvier <cbouvi@cpan.org>

COPYRIGHT & LICENSE

Copyright (C) 2006 Cédric Bouvier, All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 133:

Non-ASCII character seen before =encoding in 'Cédric'. Assuming CP1252