in reply to TIMTOWTDI Challenge: Create a filename

I like the idea by setebos of using gettimeofday for high-granularity time.  But I'd prefer a one-to-one mapping between timeofday and the filename, so, using the transliteration operator 'y', along with the most common letters (but including all of the vowels, even 'y'):
use strict; use warnings; use Time::HiRes qw/gettimeofday/; while (1) { my $fname = create_filename_from_current_time(); print "Filename is '$fname'\n"; } sub create_filename_from_current_time { (my $fname = gettimeofday) =~ y/0-9/etaonirsuy/; return $fname; }
This produces output of the sort:
Filename is 'taotiaueta.retry' Filename is 'taotiaueta.retso' Filename is 'taotiaueta.retsu' Filename is 'taotiaueta.retuo' Filename is 'taotiaueta.retuu' Filename is 'taotiaueta.retya' Filename is 'taotiaueta.retys' Filename is 'taotiaueta.reaea' Filename is 'taotiaueta.reaes' Filename is 'taotiaueta.reatt' Filename is 'taotiaueta.reatr' Filename is 'taotiaueta.reaat' Filename is 'taotiaueta.reaai' Filename is 'taotiaueta.reao'
I like that the "extension" of the first filename in the list is coincidentally a real word!

s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Replies are listed 'Best First'.
Re^2: TIMTOWTDI Challenge: Create a filename
by andreas1234567 (Vicar) on Jan 11, 2009 at 14:05 UTC
    Nice. If one were to make that
    y/0-9/abcdefghij/;
    the output would be human readable in sort order as suggested by dwhite20899 above.
    --
    No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]
        Won't that be over 300 years from now? If that's really a problem, just add sprintf '%17.6f' or whatever to the mix.