I feel so dumb. I thought this was a tough one to figure out. So anyway, I went ahead and wrote a script that generates nice PDF bingo cards:
#!/usr/bin/perl -w use strict; use PDFLib; my @words = <DATA>; chomp @words; warn("got @words\n"); my $cards = shift @ARGV || die "Must supply number of cards\n"; print "Making $cards bingo cards\n"; my $pdf = PDFLib->new( filename => "bingo.pdf", papersize => "a4", creator => "Matt Sergeant", author => "Heather Sergeant", title => "Bingo!", ); foreach my $i (1..$cards) { my %seen; print "Card $i\n"; $pdf->start_page; $pdf->set_font(face => "Helvetica", size => 30, bold => 1); $pdf->print_boxed("Bingo!", mode => "center", x => 0, y => 740, w +=> 595, h => 50); $pdf->rect(x => 100, y => 200, w => 400, h => 400); $pdf->stroke; $pdf->set_font(face => "Helvetica", size => 20, bold => 0); for my $x (1..4) { for my $y (1..4) { my $word; while (1) { my $index = rand(@words); $word = $words[$index]; if (!$seen{$word}) { $seen{$word}++; last; } } $pdf->print_boxed($word, mode => "center", x => (100 + (($ +x - 1) * 100)), y => (160 + (($y - 1) * 100)), w => 100, h => 100); if ($y != 1) { $pdf->move_to( 100, (200 + (($y - 1) * 100)) ); $pdf->line_to( 500, (200 + (($y - 1) * 100)) ); $pdf->stroke; } } if ($x != 1) { $pdf->move_to( (100 + (($x - 1) * 100)), 200 ); $pdf->line_to( (100 + (($x - 1) * 100)), 600 ); $pdf->stroke; } } } $pdf->finish; 1; __DATA__ WORDS HERE
Fill the DATA section with the things you want on the bingo card (maybe it's just numbers, in my case it was words). Remember to include at least 16 or you end up in an infinite loop ;-)

In reply to Re: Bingo Challenge by Matts
in thread Bingo Challenge by Matts

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.