PApp::Util - various utility functions that didn't fit anywhere else
use PApp::Util;
- format_source $source
-
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.
- dumpval any-perl-ref
-
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.
digest(args...)
-
Calculate a SHA1 digest and return it base64-encoded. The result will
always be 27 characters long.
- append_string_hash $hashref1, $hashref2
-
Appends all the strings found in $hashref2 to the respective keys in
$hashref1 (e.g. $h1->{key} .= $h2->{key} for all keys).
- @ = uniq @array/$arrayref
-
Returns all the elements that are unique inside the array/arrayref. The
elements must be strings, or at least must stringify sensibly (to make
sure the results are predictable, always pass in an arrayref).
- sv_peek $sv
-
Returns a very verbose dump of the internals of the given sv. Calls the
sv_peek
core function. If you don't know what I am talking then this
function is not for you.
- fetch_uri $uri
-
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.
- find_file $uri [, \@extensions] [, @bases]
-
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.
- load_file $uri [, @extensions]
-
Locate the document specified by the given uri using
find_file
, then
fetch and return it's contents using fetch_uri
.
the PApp manpage.
Marc Lehmann <pcg@goof.com>
http://www.goof.com/pcg/marc/