Generate Random Text with Perl using Text::Lorem

Text::Lorem

Sepecially for testing purposes this is an easy way to generate random text. You can say how many words you would like to have and the words method of Text::Lorem will return a string with that many words.

examples/text_lorem.pl

use strict;
use warnings;

use Text::Lorem;

sub create_payload {
    my $tl = Text::Lorem->new();
    return {
        fname   => $tl->words(1),
        lname   => $tl->words(1),
        address => $tl->words(7),
    }
}

use Data::Dumper qw(Dumper);
print Dumper create_payload();

=head1 Output

$VAR1 = {
          'fname' => 'quaerat',
          'address' => 'est enim libero aut sit architecto quis',
          'lname' => 'aliquam'
        };

=cut


Author

Gabor Szabo (szabgab) Gabor Szabo