rendered paste body#!perl -w
$file = 'c:/documents and settings/rcampbell/desktop/scripts/lotto.txt';
open (FILE, $file) || die "Can't open $file: $!\n";
@LINES=<FILE>;
close(FILE);
$count=0;
$winner=$LINES[0];
foreach $lotto (@LINES){
if($count==0){
$first=substr($winner,0,2);
$second=substr($winner,2,2);
$third=substr($winner,4,2);
$fourth=substr($winner,6,2);
$fifth=substr($winner,8,2);
$bonus=substr($winner,10,2);
$count++;
print "Winner: $first-$second-$third-$fourth-$fifth+$bonus\n\n";
next;
}
$num=0;
$one=substr($lotto,0,2);
$two=substr($lotto,2,2);
$three=substr($lotto,4,2);
$four=substr($lotto,6,2);
$five=substr($lotto,8,2);
$six=substr($lotto,10,2);
$cnt=0;
@numbers = ($one,$two,$three,$four,$five);
$win = 0;
foreach $numb (@numbers){
if($numb =~ m/$first|$second|$third|$fourth|$fifth/){
$num=$num+1;
$cor+=1;
}
$cnt=$num;
}
if($six == $bonus){
$num=$num+10;
$cnt=$num+$cnt;
$cor+=1;
}
if($num == 15){
$win = "JACKPOT";
}
elsif($num == 14){
$win = "\$10,000";
}
elsif($num == 13){
$win = "\$150";
}
elsif($num == 12){
$win = "\$10";
}
elsif($num == 11){
$win = "$num\t\$3";
}
elsif($num == 10){
$win = "\$2";
}
elsif($num == 5){
$win = "\$250,000";
}
elsif($num == 4){
$win = "\$150";
}
elsif($num == 3){
$win = "\$7";
}
print "$one\-$two\-$three\-$four\-$five\+$six\t$win\n";
}