Cobo has asked for the wisdom of the Perl Monks concerning the following question:
Any feedback you could offer would be appreciated, thanks.#!/usr/local/bin/perl use CGI ':standard'; print header; print start_html('Tic Tac Toe'), start_form, "Clear the boxes? ", radio_group( -name=>'clear', -Values=>['yes','no',], -default=>'no'), p, "What are you playing? ", radio_group( -name=>'team', -Values=>['X','O',], -default=>'X'), p, "Across: ", radio_group( -name=>'across', -Values=>[1,2,3,], -default=>1), p, "Down: ", radio_group( -name=>'down', -Values=>[1,2,3,], -default=>1), p, submit, end_form, hr; if (param()) { $across = (param('across')); $down = (param('down')); $team = (param('team')); $move = $down."_".$across; $file="../tic2.htm"; $file2="../tic.htm"; open FILE, "<$file" or die "Sorry $!"; open FILE2, ">$file2" or die "Sorry $!"; for $line (<FILE>) { $line =~ s/<! $move ><img src=bla.bmp>/<! $move ><img src=$team.bmp>/g +; #The above checks each line of tic2.htm for the move selected (ex. 1_2 +) and replaces #that squares image bla.bmp with either O.bmp or X.bmp print FILE2 $line; }; close FILE2; close FILE; #Closes the filehandles so that their uses (read, write) can be revers +ed open FILE, ">$file" or die "Sorry no luck opening file"; open FILE2, "<$file2" or die "Sorry"; for $line (<FILE2>) { print FILE $line; }; close FILE; close FILE2; if ((param('clear')) eq 'yes') { open FILE, "<$file" or die "Sorry $!"; open FILE2, ">$file2" or die "Sorry $!"; for $line (<FILE>) { $line =~ s/X/bla/g; $line =~ s/O/bla/g; print FILE2 $line; }; close FILE; close FILE2; open FILE, ">$file" or die "Sorry $!"; open FILE2, "<$file2" or die "Sorry $!"; for $line (<FILE2>) { print FILE $line; }; }; }; print end_html;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Seeking feedback on Tic-Tac-Toe
by synapse0 (Pilgrim) on Jul 12, 2001 at 03:20 UTC | |
|
Re: Seeking feedback on Tic-Tac-Toe
by synapse0 (Pilgrim) on Jul 12, 2001 at 02:59 UTC | |
by Cobo (Scribe) on Jul 12, 2001 at 04:01 UTC | |
by the_slycer (Chaplain) on Jul 12, 2001 at 04:20 UTC | |
by synapse0 (Pilgrim) on Jul 12, 2001 at 04:28 UTC |