Next Tricks of the Wizards 150

Overloading: Y2K Detection Example

        package y2k;
        ...
        sub fake_localtime {
          unless (wantarray) {
            return @_ ? localtime(@_) : localtime();
          }
          my @lt = @_ ? localtime(@_) : localtime();
          $lt[5] = { YEAR => $lt[5] };
          bless $lt[5] => 'y2k';
          @lt;
        }


Next Copyright © 2003 M. J. Dominus