[Oc-pm] Perl Challenge 4

Tony tony at metracom.com
Mon Apr 29 22:10:20 PDT 2013



Here's an example solving Perl challenge 4 with a CPAN Perl module.

Remember CPAN is your friend.


#!/usr/bin/perl

# Perl challenge 4
# Reading cards from stdin file

use Games::Cards::Poker qw(:all);

open(FIN,"cards.txt") or die ("Can't open input file\n");

while(<FIN>) {
   chomp;
   @cards  = split(/ /);
   $total_wins++ if( ScoreHand(@cards[5..9]) >  ScoreHand(@cards[0..4]));
}
print "player1 wins: $total_wins\n";
close(FIN);


More information about the Oc-pm mailing list