On Nov 10, 2007 5:10 PM, Omega -1911 <[EMAIL PROTECTED]> wrote:
>What I will need to be able to do
> is place the most common 5 numbers (before the word "powerball") into
> an array then place the powerball numbers into another array. Thanks
> in advance.
>
> @liners = split /(\s\[0-9],\s)Powerball:\s[0-9]/,$data_string;
>
> _DATA_
> 22, 29, 35, 46, 52, Powerball: 2, Power Play: 5
> 1, 31, 38, 40, 53, Powerball: 42, Power Play: 2
> 6, 16, 18, 29, 37, Powerball: 24, Power Play: 2
>
Hi,
I just think the data stru you need is a hash not two arrays.The
entire code can be:
use strict;
use warnings;
use Data::Dumper;
my %hash;
while() {
my ($li,$powerb) = /^(.+)\,\s*Powerball\:\s*(\d+)/;
$hash{$powerb} = [split/,/,$li];
}
print Dumper \%hash;
__DATA__
22, 29, 35, 46, 52, Powerball: 2, Power Play: 5
1, 31, 38, 40, 53, Powerball: 42, Power Play: 2
6, 16, 18, 29, 37, Powerball: 24, Power Play: 2
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/