
PTools::List - Create lists of things indexed by a label

This document describes version 1.04, released October, 2004

use PTools::List;
$notice = new PTools::List; # start Notices
$notice->add("Error","Err1","Err2"); # add two Errors
$warn = new PTools::List("Warning","A warning");
$warn->add("Warning","Another warning"); # add to Warnings
$notice->add($warn); # add to Notices
print $notice->dump; # view contents
print $notice->format(); # format output
print $notice->summary(); # format summary

The new method is called to create a new object that is used to collect various lists of things. Each list will have a unique label name and zero or more items in the list. Initial values are optional and may be added at any time.
This method is used to add items to an existing list.
Reset the list named by Label to an empty value.
The get and return method will return any value(s) contained in the list named by Label.
Warning: Perl references may be stored in any list. However, if you do so, make sure to invoke this method in list context, or you will be very disappointed by the result. (In scalar context, you will get a string that looks like a reference, and it will be extremely frustrating spending time debugging that!)
For example:
$hashRef = { foo => "bar", abc => "xyzzy" };
$list = new PTools::List( 'test', $hashRef );
(@items) = $list->return(); # MUST set "(@items) = " here.
Check to see if any items are in the list indicated by Label.
Returns a formatted string of the current contents. An optional list of one or more Labels can be added to limit the output to only contain one or some Label identifiers.
Returns a formatted summary of the current contents. An optional list of one or more Labels can be added to limit the output to only contain one or some Label identifiers. An optional Title can be added to the output.
During testing or debugging this method will return a string showing the raw contents of the current object. Output includes where the method was called from, and the class and object where the method resides.

Perl references may be stored in any list. However, if you do so, make sure to invoke this method in list context, or you will be very disappointed by the result.
In scalar context, you will get a string that looks like a reference, and it will be extremely frustrating spending time debugging that!

Chris Cobb [no dot spam at ccobb dot net]

Copyright (c) 1998-2007 by Chris Cobb. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.