[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Sheflug] Unique temporary filename



#!/usr/bin/perl

sub rand_name {
  my $name;
  my  [at] letters = ('A'..'Z', 'a'..'z', '0'..'9');

  for (1 .. $_[0]) {
    $name .= $letters[rand (scalar @letters)];
}

print rand_name(20);

That lot will give you a random 20 character string.

You can always add the process id ($$) and time (localtime).

Cheers.
Baz.

--
Barrie J. Bremner         OpenPGP public key ID: F78CEE08
TheEnglishman [at] ecosse.net   http://barriebremner.com/

___________________________________________________________________

Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html

  GNU the choice of a complete generation.