Puma
P e r l   U n i v e r s a l   M a r k u p   D o c u m e n t a t i o n
SourceForge.net Logo

Puma::Util::Conversion
Every project needs conversion utilities.
CTIME2EPOCH()
This function provides function that is missing from the base Perl libraries - the conversion of canonical time to epoch seconds:
   use Puma::Util::Conversion qw( ctime2epoch );

   my $ltime = localtime();
   print "$ltime (localtime)\n";
   print ctime2epoch($ltime) ." (epoch seconds)\n";
produces the output:
   Fri Feb  8 15:03:27 2002 (localtime)
   1013209407 (epoch seconds)
As you can see from the example, the ctime2epoch() function takes the output of locatime() and converts it to epoch seconds. This makes it much easier to do date math and sort by date when you are using epoch seconds. You can convert epoch seconds back to canonical time by using localtime().
PHONEPAD() AND NORTELPHONEPAD()
These are two cute little functions that convert a string into the corresponding numbers on a phone. The letters on a Nortel phone are configured slightly differently than most phones with the 'Q' and 'Z' on the number '0' rather than on the '7' and the '9'.
   use Puma::Util::Conversion qw( phonepad nortelphonepad );

   my $dial = '1 (800) Quiz Man';
   print "$dial (original)\n";
   print phonepad($dial) ." (phonepad)\n";
   print nortelphonepad($dial) ." (nortelphonepad)\n";
produces the output:
   1 (800) Quiz Man (original)
   1 (800) 7849 626 (phonepad)
   1 (800) 0840 626 (nortelphonepad)