I have a few of comments:
- You shouldn't stringify your numbers. $elapsed > 3600 works just fine thanks.
- You should separate your "chopping up time" logic from your presentation logic. I'd write a subroutine that does what you need to an elapsed-time value and returns an array of seconds, minutes, hours, etc.
- Have you checked CPAN? I'm fairly sure there's already a module that does this (though I've not had occasion to use it).
As to a better way than your method, you might want to use integer division and modulo arithmetic:
$days = int($time/86400);
$time %= 86400; # leave only the part that's less than a d
+ay
$hours = int($time/3600);
$time %= 3600; # leave only the part that's less than an
+hour;
... # and so on