HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/share/doc/libbytes-random-secure-perl/examples/random-from.pl
use strict;
use warnings;
use utf8;

use Bytes::Random::Secure qw( random_string_from );

my $quantity = 64;

my $bag = 'abcde';

# Generate a random string of 64 characters, each selected from
# the "bag" of 'a' through 'e', inclusive.

my $string = random_string_from( $bag, $quantity );

print $string, "\n";

# Unicode strings are ok too (Perl 5.8.9 or better):

if( $^V && $^V ge v5.8.9 ) {
  
  $string = random_string_from( 'Ѧѧ', 64 );

  binmode STDOUT, ':encoding(UTF-8)';
  print $string, "\n";

}