in reply to Re^2: 52 Perl Pickup
in thread 52 Perl Pickup

Which can be whittled down to a more useful PNB dealer which would normally be written to a file. I did it to feed the the GIB command-line bridge engine.
#!/usr/bin/perl ## Dealing cards in PBN (Portable Bridge Notation) ## Using tr to avoid the awesome card-sort map ## mock names for easy sorting my @suit = qw(f g h i); my @rank = (2..9, qw(a b c d e)); my @seps = qw(g. h. i.); sub shuffle { for (my $i = $#_ ; $i > 0 ; $i--) { @_[$_, $i] = @_[$i, $_] for rand $i+1 } return @_; } ## reformats one hand at a time sub pbnFormat { push (@_, @seps) ; local $string = join(``, sort{$b cmp $a}@_); $string =~ tr/abcdefghi/TJQKA/d; return $string; } my @deck = shuffle(map{$rank=$_; map{"$_$rank"}@suit}@rank); for(1..4) { print pbnFormat splice @deck,0,13; print "\n"; }