SWISH::Prog::Utils - utility variables and methods
use SWISH::Prog::Utils; # use the utils
This class provides commonly used variables and methods shared by many classes in the SWISH::Prog project.
Regular expression of common file type extensions.
Hash of MIME types to their equivalent parser.
Returns MIME type for url. If ext is used, that is checked against MIME::Types. Otherwise the url is parsed for an extension using path_parts() and then fed to MIME::Types.
Returns array of path, file and extension using the File::Basename module. If regex is missing or false, uses $ExtRE.
Similar to the XML::Simple XMLout() feature, perl_to_xml() will take a Perl data structure ref and convert it to XML, using root_element as the top-level element.
If strip_plural is a true value and not a CODE ref, any trailing s character will be stripped from the enclosing tag name whenever an array of hashrefs is found. Example:
s
my $data = { values => [ { two => 2, three => 3, }, { four => 4, five => 5, }, ], }; my $xml = $utils->perl_to_xml($data, 'data', 1); # $xml DOM will look like: <data> <values> <value> <three>3</three> <two>2</two> </value> <value> <five>5</five> <four>4</four> </value> </values> </data>
Obviously stripping the final s will not always render sensical tag names. Pass a CODE ref instead, expecting one value (the tag name) and returning the tag name to use:
use Lingua::EN::Inflect; my $xml = $utils->perl_to_xml($data, 'data', \&Lingua::EN::Inflect::PL);
Peter Karman, <perl@peknet.com>
Please report any bugs or feature requests to bug-swish-prog at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SWISH-Prog. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-swish-prog at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc SWISH::Prog
You can also look for information at:
Mailing list
http://lists.swish-e.org/listinfo/users
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=SWISH-Prog
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/SWISH-Prog
CPAN Ratings
http://cpanratings.perl.org/d/SWISH-Prog
Search CPAN
http://search.cpan.org/dist/SWISH-Prog/
Copyright 2008-2009 by Peter Karman
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
http://swish-e.org/
To install SWISH::Prog, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SWISH::Prog
CPAN shell
perl -MCPAN -e shell install SWISH::Prog
For more information on module installation, please visit the detailed CPAN module installation guide.