View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Tatsuhiko Miyagawa > Dunce-time > Dunce::time



Annotate this POD

View/Report Bugs
Module Version: 0.02   Source  


Dunce::time - Protects against sloppy use of time.


  use Dunce::time;

  my $this = time;
  my $that = time;

  my @sorted = sort $this, $that; # die with an error
  my @numerically_sorted = sort { $a <=> $b } $this, $that; # OK


On Sun Sep 9 01:46:40 2001 GMT, time_t (UNIX epoch) reaches 10 digits. Sorting time()'s as strings will cause unexpected result after that.

When Dunce::time is used, it provides special version of time() which will die with a message when compared as strings.


Just use the module. If it detects a problem, it will cause your program to abort with an error. If you don't like this behaviour, you can use the module with tags like ":WARN" or ":FIX".

  use Dunce::time qw(:WARN);

With ":WARN" tag, it will just warn instead of dying.

  use Dunce::time qw(:FIX);
  @sorted = sort @time; # acts like sort { $a <=> $b } @time;

With ":FIX" tag, it will warn and change the comparison behaviour so that it acts like compared numerically.


You store the variables into storage (like DBMs, databases), retrieve them from storage, and compare them as strings ... this can't detect in such a case.


Tatsuhiko Miyagawa <>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Dunce::time::Zerofill, D::oh::Year, overload, perl

syntax highlighting: