From the POD:
shuffle
my $shuffled = shuffle($data, ...);
my $shuffled = shuffle(@data);
my $shuffled = shuffle(\@data);
Returns an array reference containing a random ordering of the
supplied arguments (i.e., shuffled) by using the Fisher-Yates
shuffling algorithm. If called with a single array reference
(fastest method), the contents of the array are shuffled in situ.
The shuffle command takes a list/array or array ref, and returns the
mixed results inside an array ref.
Strings are not arrays. If you want to shuffle the 'components' of a
string you need to split it in some manner.
#!/usr/bin/perl
use strict;
use warnings;
use Math::Random::MT::Auto qw(shuffle);
MAIN:
{
print 'Enter string : ';
my $string = <STDIN>;
chomp($string);
# Shuffle characters
my @chars = split('', $string);
my $shuffled_chars = shuffle(@chars);
print('Shuffled chars: ', @{$shuffled_chars}, "\n");
# Shuffle words
my @words = split(' ', $string);
my $shuffled_words = shuffle(@words);
print('Shuffled words: ', join(' ',@{$shuffled_words}), "\n");
}
print("Done\n");
exit(0);