I've taken a few shortcuts for you, and added a check to be sure you don't get more than one occurrence of any number in a line.
$| = 1;
print qq(
-------------------------------------------------------
National Lottery Number Picker
-------------------------------------------------------
How many lines do you want to play? );
my $num_lines = <STDIN>;
$num_lines =~ s/\D+//g;
die "Good. Don't waste your money!\n" unless $num_lines;
my @numbers = (1..49);
my $output;
for (1..$num_lines) {
my @line = ();
my %chosen = ();
for (1..6) {
my $element;
while (!$element || $chosen{$element}) {
$element = $numbers[rand @numbers];
}
push @line, $element;
$chosen{$element} = 1;
}
$output .= join "\t", sort {$a <=> $b} @line;
$output .= "\n";
}
print $output;
# Then, do your e-mail thing. Send $output as the message
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.