in reply to How to sort filename based on time via FTP

($ckseq = substr($name,6,6)) =~ s/^0+//g;
Are you sure it does what you want? That will change $name in-place (becase substr is magical). Also, $ckseq will always be 1. If you want the number of 0s that should be s/0//g (or, better, tr/0//, which will also fix the first bug)