The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

XAS::Utils - A Perl extension for the XAS environment

SYNOPSIS

 use XAS::Class
   version => '0.01',
   base    => 'XAS::Base',
   utils   => 'db2dt dt2db'
 ;

 printf("%s\n", dt2db($dt));

DESCRIPTION

This module provides utility routines that can by loaded into your current namespace.

METHODS

db2dt($datestring)

This routine will take a date format of YYYY-MM-DD HH:MM:SS and convert it into a DateTime object.

dt2db($datetime)

This routine will take a DateTime object and convert it into the following string: YYYY-MM-DD HH:MM:SS

trim($string)

Trim the whitespace from the beginning and end of a string.

ltrim($string)

Trim the whitespace from the end of a string.

rtrim($string)

Trim the whitespace from the beginning of a string.

compress($string)

Reduces multiple whitespace to a single space.

spawn

Run a cli command with timeout. Returns output from that command.

-command

The command string to run.

-timeout

An optional timeout in seconds. Default is none.

exitcode

Decodes perls exit code of a cli process. Returns two items.

 Example:

     my @output = spawn(-command => "ls -l");
     my ($rc, $sig) = exitcode();

daemonize

Become a daemon. This will set the process as a session lead, change to '/', clear the protection mask and redirect stdin, stdout and stderr to /dev/null.

hash_walk

This routine will walk a HOH and does a callback on the key/values that are found. It takes three named parameters:

-hash

The hashref of the HOH.

-keys

An arrayref of the key levels.

-callback

The routine to call with these parameters:

$key

The current hash key.

$value

The value of that key.

$key_list

A list of the key depth.

keygen

This routine takes a set of parameters formated like a ExtJS 4.1 request and generates a md5 hash value from them.

-url

A URL.

-params

The parameters.

init_module($module, $options)

This routine will load and initialize a module. It takes one required parameter and one optinal parameter.

$module

The name of the module.

$options

A hashref of optional options to use with the module.

load_module($module)

This routine will load a module.

$module

The name of the module.

SEE ALSO

Badger::Utils

XAS

AUTHOR

Kevin L. Esteb, <kevin@kesteb.us>

COPYRIGHT AND LICENSE

Copyright (C) 2012 by Kevin L. Esteb

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.