Here's my entry. I took a different approach than James.
I don't like to collect the data and produce the report at the
same time. Both our approaches are valid, though. I tried to
stick with James' report structure.

    Perl allows us to be selective with our styles. I find it
a comfortable alternative to many languages that force the
programmer to think in severely limited ways.


#!/usr/bin/perl

use strict;
use warnings;

# List::Util is available on CPAN for 5.6.0 and up
# It comes with 5.8.1 and up.
use List::Util 'shuffle';

# randomize 52 numbers
my @random_numbers = shuffle 1 .. 52;

# randomly choose ten power balls
my @powerballs = ( shuffle 1 .. 52 )[ 0 .. 9 ];

# create an array of arrays to hold the tickets and power balls
my @tickets =
    map [
        @random_numbers[ $_ * 5 .. $_ * 5 + 4 ],
        $powerballs[ $_ ],
    ],
    0 .. 9;

# print report
foreach my $ticket ( @tickets ) {
    printf '%02d  ' x 5 . "-  %02d\n", @$ticket;
}

__END__


HTH,

Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to