in reply to unique file ID
Perhaps using GUIDs?
Linux etc.:
myMac:~ karl: uuidgen EBB88FE7-1262-43BD-9017-7CAEEA2E8627
Windows, using Powershell:
PS C:\Documents and settings\karl> [System.Guid]::NewGuid().ToString() 995187c6-993a-41e3-b249-e2c013d71c73
Should be unique enough. There are also some Modules for this on but i didn't use them.
Update:
I knew i saw something interesting about this some time ago: Generate GUID from a string by GrandFather.
Update 2:
Btw...i posted already some other variations on this "unique" stuff...
#!/usr/bin/perl + + use strict; use warnings; my ( @l, @u, @n, @p, $i, $j ); open( URANDOM, "</dev/urandom" ) || die $!; read( URANDOM, $_, 4 ); close URANDOM; srand( unpack( "L", $_ ) ); @l = ( "a" .. "z" ); @u = ( "A" .. "Z" ); @n = ( 0 .. 9 ); push( @p, splice( @l, int( rand(@l) ), 1 ) ) for ( 1 .. 10 ); push( @p, splice( @u, int( rand(@u) ), 1 ) ) for ( 1 .. 10 ); push( @p, splice( @n, int( rand(@n) ), 1 ) ) for ( 1 .. 2 ); for ( $i = @p ; --$i ; ) { $j = int( rand( $i + 1 ) ); next if $i == $j; @p[ $i, $j ] = @p[ $j, $i ]; } print join( "", @p ) . qq(\n); __END__ Karls-Mac-mini:monks karl$ ./random_filename.pl gRjyL1ivolIPHsJx0MCSeQ
...and i still think that this is not a bad ("easy") approach - if you don't plan to deploy world wide ;-)
Regards, Karl
«The Crux of the Biscuit is the Apostrophe»
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: unique file ID
by tobyink (Canon) on Apr 30, 2013 at 12:56 UTC | |
by karlgoethebier (Abbot) on Apr 30, 2013 at 18:31 UTC |
In Section
Seekers of Perl Wisdom