PApp::Util - various utility functions that didn't fit anywhere else
use PApp::Util;
This module offers various utility functions that cannot be grouped into other categories easily.
Formats a file supposed to be some "sourcecode" (e.g. perl, papp, xslt etc..) into formatted ascii. It includes line numbering at the front of each line and handles embedded "#line" markers.
Tries to dump the given perl-ref into a nicely-formatted human-readable-format (currently uses either Data::Dumper or Dumpvalue) but tries to be very robust about internal errors, i.e. this functions always tries to output as much usable data as possible without die'ing.
Converts a JSON string into the corresponding perl data structure.
Converts a perl data structure into its JSON representation.
Calculate a SHA1 digest and return it base64-encoded. The result will always be 27 characters long.
Appends all the strings found in $hashref2 to the respective keys in $hashref1 (e.g. $h1->{key} .= $h2->{key} for all keys).
Returns all the elements that are unique inside the array. The elements must be strings, or at least must stringify sensibly.
Returns a very verbose dump of the internals of the given sv. Calls the sv_peek (sv_dump) core function. If you don't know what I am talking about then this function is not for you. Or maybe you should try it.
sv_peek
sv_dump
Tries to fetch the document specified by $uri, returning undef on error. As a special "goody", uri's of the form "data:,body" will immediately return the body part.
$uri
undef
Try to locate the specified document. If the uri is a relative uri (or a simple unix path) it will use the URIs in @bases and PApp's search path to locate the file. If bases contain an arrayref than this arrayref should contain a list of extensions (without a leading dot) to append to the URI while searching the file.
@bases
Locate the document specified by the given uri using find_file, then fetch and return it's contents using fetch_uri.
find_file
fetch_uri
Takes text and transforms it to a mime message header suitable for message headers. If the text is US-ASCII it will be returned unchanged, otherwise it will be encoded according to RFC 2047 (it will be split into multiple CRLF-Tab-separated components of no longer than 75 characters, with the first component not be longer than 40 characters).
Same as inet_ntoa/inet_aton, but works on (numerical) IPv4 and IPv6 addresses.
ipv6 not yte implemented
A very primitive form of source filtering can be implemented using filter_add, filter_read and filter_simple. Better use the Filter module family, though.
filter_add
filter_read
filter_simple
Return a nonce suitable for cryptographically.
Convert the given octet string into a human-readable ascii text, using only a-zA-Z0-9 characters (base62 encoding).
PApp.
Marc Lehmann <schmorp@schmorp.de> http://home.schmorp.de/
To install PApp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PApp
CPAN shell
perl -MCPAN -e shell install PApp
For more information on module installation, please visit the detailed CPAN module installation guide.