One solution to make your code survive longer is: (solution is tested with various dates set to points after 2038)
- turn on big int for the right lexical scopes, and
- do this convertion:
my $t = time();
$t += 2 ** 32 if ($t < 0);
This would make the epcho value increase smoothly even after 2038 (but not forever).
The logic behind the convertion: time() returns (- 2** 31) for 2038-01-18-20:14:07, which should be 2 * 31; returns (-2**31 + 1) for 2038-01-18-20:14:08, which should be (2 ** 31 + 1) and ... so the difference between what returned from time() and what it should be is always 2 ** 32.