• Autore dell'articolo:
  • Categoria dell'articolo:PERL
  • Commenti dell'articolo:0 Commenti

Non si sa mai a qualcuno al volo può servire 🙂 Vi copio una funzione per la generazione casuale di stringhe in PERL o Perl Random String Generator. La funzione consente di passare una variabile numerica per specificare la lunghezza della stringa.

sub random_string_generator_perl
{
#lunghezza della stringa da generare
 my $length_of_random_string=shift;
# the random string to generate
my @chars=('a'..'z','A'..'Z','0'..'9');
 my $random_string;
 foreach (1..$length_of_random_string) 
 {
 $random_string_perl.=$chars[rand @chars];
 }
 return $random_string_perl;
}
my $randomID= &random_string_generator_perl(11);

Lascia un commento