Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
The grid generator code:
#!/usr/bin/perl -w use strict; # I wrote this to generate a file, not be a cgi script, but you could. +.. # use; open GRID, '>../html/grid.html' or die $!; select GRID; print "<HTML><BODY>\n"; print "<FORM method=GET action=> \n"; my $cellwidth = '20'; # pixel or percent my $cellheight = '4'; # pixels only my $counter = 0; sub Solid { return "<TD WIDTH='$cellwidth' HEIGHT='$cellheight' ". "BGCOLOR='BLACK'>&nbsp;</TD>\n"; } sub Open { return "<TD WIDTH='$cellwidth' HEIGHT='$cellheight' ". "BGCOLOR='WHITE' VALIGN='BOTTOM'><input type=text size=1 na +me='x' max length=1></TD>\n"; } sub Numbered { ++$counter; return "<TD WIDTH='$cellwidth' HEIGHT='$cellheight' BGCOLOR='WHITE +'". "ALIGN='LEFT' VALIGN='TOP'><FONT SIZE=-2>$counter</FONT><in +put type=t ext size=1 name='x' maxlength=1></TD>\n"; } # These two arrays are used to generate the grid. # numbers in @line correspond to the functions in @type. # 0 black box, 1, white box, 2, numbered box. my @type = ( \&Solid, \&Open, \&Numbered ); my @line = ( '020000002000002000000000000', '020000002000002000000000000', '010200201021111110000020000', '010100101000001002111110000', '010102111121111111000010020', '010100000010001001000202010', '211121111110001021111101010', '100010000010001001000101010', '100010212111001002111111110', '100010001010000001000101010', '100010001000021111120001010', '102111001000000000010001010', '101010211000000000010200200', '101010001000000000211111111', '101010000000211111010100100', '102211111111100000000100100', '100100000000102020000100100', '000100000000101010000100100', '002111000211111111100000000', '000000000000101000000000000', '000000211111111000000000000', ); print "<TABLE BORDER=1 SHADE=0>\n"; foreach ( @line ) { print "<TR>\n"; print map { &{$type[$_]} } split //; print "</TR>"; } print "\n</TABLE>"; print "<input type=submit value=\"I'd like to solve the puzzle please\ +">\n"; print "\n</form>"; print "</body></html>";

And the processing code:

#! /usr/bin/perl -w require (""); $success=0; print "Content-type: text/html\n\n"; @my_query = split(/&/,$ENV{'QUERY_STRING'}); foreach (@my_query) { @key_value = split(/=/,$_); push @solved, $key_value[1]; } $solved_str = join('',@solved); if ($solved_str eq "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx +yzabcdefgh ijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz +abcdefghij klmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzab +cd") { $success=1; } if ($success) { print << 'End_Of_Text'; <html> <head> <title> Success. </title> </head> <body bgcolor=#004400 text=ffffff> <h3>Hooray! You've solved the puzzle!</h3> Congrats. Go out, have a beer. Eat some salami. </body> </html> End_Of_Text } else { print << 'End_Of_Text'; <html> <head> <title> Failure. </title> </head> <body bgcolor=#440000 text=ffffff> <h3>Sorry, try again.</h3> One of your answers is incorrect. Click back and try again. </body> </html> End_Of_Text }

In reply to OL Crossword puzzle server/client by wombat

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2023-12-03 23:26 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (20 votes). Check out past polls.