Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl print "-------------------------------------------------------\n"; print "National Lottery Number Picker \n"; print "-------------------------------------------------------\n\n"; print "How many lines do you want to play?\n"; print "Lines.....:"; $lines = <STDIN>; @numbers = (1..49); srand; print "\n"; &chooseline(); $i = 1; sub chooseline { while ($i < $lines) { &genline(); push @lines, @line; $i++; if ($i eq $lines) { print "\n\n"; last; } } print "\n\n"; } sub genline { @line = ''; $e = 1; while ($e ne "7") { $index = rand @numbers; $element = $numbers[$index]; print " $element"; if ($e eq "6") { print "\n"; push @line, $element; $newline = "\n"; push @line, $newline; last; } else { push @line, $element; } $e++; } } print "(E)mail Results / (Q)uit\n\n"; print "Action....:"; $action = <STDIN>; exit if $action =~ /^Q/i; if ($action =~ /^E/i) { print "\nEmail address...:"; $email = <STDIN>; open (MAIL, "|/usr/sbin/sendmail -t"); print MAIL "To: $email\n"; print MAIL "From: Lottery Generator\n"; print MAIL "Subject: Your Lottery Numbers\n"; foreach $lin (@lines) { print MAIL "$lin "; } close (MAIL); }
Edit kudra, 2001-11-04 Changed title
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Some help
by joealba (Hermit) on Nov 04, 2001 at 01:51 UTC | |
|
Re: Some help
by Anonymous Monk on Nov 04, 2001 at 02:37 UTC | |
|
Re: Some help
by tfrayner (Curate) on Nov 04, 2001 at 01:30 UTC | |
|
Re: Some help
by rchiav (Deacon) on Nov 04, 2001 at 01:53 UTC | |
|
Re: Some help
by Anonymous Monk on Nov 04, 2001 at 01:57 UTC |