| 1 |
#!/usr/bin/perl -w |
| 2 |
|
| 3 |
use strict; |
| 4 |
use vars qw($opt_v $opt_w $opt_s $opt_p); |
| 5 |
|
| 6 |
use Getopt::Std; |
| 7 |
use Text::Lorem; |
| 8 |
|
| 9 |
getopts("vw:s:p:"); |
| 10 |
|
| 11 |
if ($opt_v) { |
| 12 |
print usage(); |
| 13 |
exit 0; |
| 14 |
} |
| 15 |
|
| 16 |
die usage() |
| 17 |
if ((defined($opt_w) + defined($opt_s) + defined($opt_p)) > 1); |
| 18 |
|
| 19 |
my $lorem = Text::Lorem->new; |
| 20 |
if ($opt_w) { |
| 21 |
print $lorem->words($opt_w); |
| 22 |
} |
| 23 |
elsif ($opt_s) { |
| 24 |
print $lorem->sentences($opt_s); |
| 25 |
} |
| 26 |
elsif ($opt_p) { |
| 27 |
print $lorem->paragraphs($opt_p); |
| 28 |
} |
| 29 |
else { |
| 30 |
print $lorem->paragraphs(1); |
| 31 |
} |
| 32 |
|
| 33 |
sub usage { |
| 34 |
return <<USAGE; |
| 35 |
$0 - Generate random Latin looking text using Text::Lorem |
| 36 |
|
| 37 |
Usage: |
| 38 |
$0 -w NUMBER_OF_WORDS |
| 39 |
$0 -s NUMBER_OF_SENTENSES |
| 40 |
$0 -p NUMBER_OF_PARAGRAPHS |
| 41 |
|
| 42 |
-w, -s, and -p are mutually exclusive. |
| 43 |
USAGE |
| 44 |
} |
| 45 |
|
| 46 |
__END__ |
| 47 |
|
| 48 |
=head1 NAME |
| 49 |
|
| 50 |
lorem - Generate random Latin looking text using Text::Lorem |
| 51 |
|
| 52 |
=head1 SYNOPSIS |
| 53 |
|
| 54 |
Generate 3 paragraphs of Latin looking text: |
| 55 |
|
| 56 |
$ lorem -p 3 |
| 57 |
|
| 58 |
Generate 5 Latin looking words: |
| 59 |
|
| 60 |
$ lorem -w 5 |
| 61 |
|
| 62 |
Generate a Latin looking sentence: |
| 63 |
|
| 64 |
$ lorem -s 1 |
| 65 |
|
| 66 |
=head1 DESCRIPTION |
| 67 |
|
| 68 |
F<lorem> is a simple command-line wrapper around the C<Text::Lorem> |
| 69 |
module. It provides the same three basic methods: Generate C<words>, |
| 70 |
generate C<sentences>, and generate C<paragraphs>. |
| 71 |
|
| 72 |
|