home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / _time_alias.al < prev    next >
Encoding:
Text File  |  2003-09-17  |  915 b   |  35 lines

  1. # NOTE: Derived from blib\lib\CGI\Session.pm.
  2. # Changes made here will be lost when autosplit is run again.
  3. # See AutoSplit.pm.
  4. package CGI::Session;
  5.  
  6. #line 1159 "blib\lib\CGI\Session.pm (autosplit into blib\lib\auto\CGI\Session\_time_alias.al)"
  7. # parses such strings as '+1M', '+3w', accepted by expire()
  8. sub _time_alias {
  9.     my ($str) = @_;
  10.  
  11.     # If $str consists of just digits, return them as they are
  12.     if ( $str =~ m/^\d+$/ ) {
  13.         return $str;
  14.     }
  15.  
  16.     my %time_map = (
  17.         s           => 1,
  18.         m           => 60,
  19.         h           => 3600,
  20.         d           => 86400,
  21.         w           => 604800,
  22.         M           => 2592000,
  23.         y           => 31536000
  24.     );
  25.  
  26.     my ($koef, $d) = $str =~ m/^([+-]?\d+)(\w)$/;
  27.  
  28.     if ( defined($koef) && defined($d) ) {
  29.         return $koef * $time_map{$d};
  30.     }
  31. }
  32.  
  33. # end of CGI::Session::_time_alias
  34. 1;
  35.