beginners:
I am looking for a class that stores zero or more items (e.g. a list)
and that provides accessors that accept and return scalar, list, and/or
array references depending upon context and object content (similar to
CGI.pm, but not exactly the same):
use WishfulThinkingListClass;
my $o = WishfulThinkingListClass->new();
$o->set('foo'); # saves one-item list
my $v = $o->get(); # returns scalar 'foo'
my @v = $o->get(); # returns one-item list ('foo')
$o->set('bar', 'baz'); # saves two-item list
$v = $o->get(); # returns arrayref ['bar', 'baz']
@v = $o-get(); # returns list ('bar', 'baz')
$o->set(['bozo']); # saves one-item list
In addition to "set", "get", I can envision instance methods "mypush",
"mypop", "myshift", and "myunshift".
Is there such an thing in standard Perl (5.10.1) or on CPAN?
TIA,
David
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/