in reply to scalar localtime() to timestamp
I use this function to create "timestamp" names suitable for backup filenames - names that are easily sorted, and unique.
The full script can be found here.
sub newname { my @t = reverse((localtime)[0..5]); $t[0]+=1900; $t[1]++; my $newbackup = sprintf("%4u-%02u-%02u-%02u-%02u-%02u_000",@t).'.zip'; $newbackup =~ s/(\d\d\d)\.zip$/substr('00'.($1+1),-3).'.zip'/e while (-e $newbackup); return $newbackup; }
HTH
Update: Minor code tidy for sake of clarity
|
|---|