in reply to faking real date/time

You can override various time-returning functions via the mechanism documented in perlsub:
package SetTime; use warnings; use strict; use Exporter (); our @ISA = 'Exporter'; our @EXPORT = qw/time localtime gmtime set_time/; our $VERSION = 0.01; sub import { my $pkg = shift; $pkg->export("CORE::GLOBAL", "time", "localtime", "gmtime"); $pkg->export(scalar(caller(0)), "set_time"); } my $time; sub set_time { $time = shift } sub time () { defined($time) ? $time : CORE::time; } sub localtime (;$) { @_ ? CORE::localtime($_[0]) : defined($time) ? CORE::localtime($time) : CORE::localtime(); } sub gmtime (;$) { @_ ? CORE::gmtime($_[0]) : defined($time) ? CORE::gmtime($time) : CORE::gmtime(); } 1;
But beware of conflict with other modules that override these (offhand, Time::localtime and Time::gmtime do this), or other ways of getting the time (POSIX, or other XS modules).