File: random-from.pl

package info (click to toggle)
libbytes-random-secure-perl 0.29-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, trixie
  • size: 224 kB
  • sloc: perl: 415; makefile: 2
file content (27 lines) | stat: -rw-r--r-- 510 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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";

}