OK, you're totally right, I should have printed my code 8^( I figured that
it would be totally easy... then I remembered that I'm a noobie and
everything is confusing 8^)
First, let me say that I'm trying to get work to buy me a Perl book, but
money at the state is tight these days. I've even gone to the *library* and
they don't have the Perl books. 8^( Oh well, that's what the Perl community
is for, right?
When the line below is commented out the only thing that gets output to the
browser window is the Start Over link
#
#push @Draw, [ split /\|/ ] while <FILE>;
#
Ok, the two parts that I'm having trouble with are:
1) getting the file data into an array (which you've helped me with so
far)...
2) printing that array out in the table at the bottom of the code.
#!/usr/local/bin/perl
#include <stdlib.h>
use CGI qw(:standard);
use strict;
print "Content-type: text/html\n\n";
print qq{
<p><a href="cards2.cgi">Start Over</a></p>
};
my @Deck; # The whole deck, orderd
my @Draw; # The current, shuffled deck
my @playedCards = param("playedCardsHidden") || "";
my @playedCardsCheckbox = param("playedCardsCheckbox") || "";
my @discardCards = param("discardCardsHidden") || "";
my @discardCardsCheckbox = param("discardCardsCheckbox") || "";
my $iterate;
my $random;
my $control;
my $counter = 0;
my $valueName;
my $turnCounter = param("turnCounter") || 0;
# if the update button has NOT been pressed.
# e.g. when the page is just run for the first time.
if (param("update") eq "no" || param("update") eq undef){
open (DECK,"deck.txt");
# when the line below is commented out
# the only thing that gets output to the browser window
# is the Start Over link (yes, when I uncomment the one
# below, I comment out the @Deck = <DECK>; line.)
#push @Draw, [ split /\|/ ] while <FILE>;
# this (as you well know) just gets each line in my file
@Deck = <DECK>;
close DECK;
@Draw = @Deck;
&Randomize (\@Draw);
# Run this code whenever the "End turn" button is pressed
}else{
$turnCounter += 1;
# Perform all the actions related to
# @inPlay
# Perform all the actions related to
# @inDiscard
# Perform all the actions realted to
# @Draw
# end of the "update" if/else loop
}
sub Randomize
{
$random = shift;
for ($iterate = @$random; --$iterate; )
{
$control = int rand ($iterate + 1);
if ($iterate == $control)
{ next; }
@$random[$iterate, $control] = @$random[$control, $iterate];
}
}
###################################
# Now we start the output section #
###################################
print qq|
<html>
<body bgcolor="#ffffff">
<form name="form" method="get" action="cards2.cgi">
<input type="hidden" name="update" value="yes">
<input type="submit" value="End Phase">
<div style="font-size:2em;">Draw Deck</div>
<table border="1" align="left">
<tr>
<th>#</th>
<th>Card Name</th>
<th>Play</th>
<th>Discard</th>
</tr>
|;
#This prints out the randomized array
#my $index=0;
#foreach my $item (@Draw) {
#$index++;
#print "List index $index:\n";
#foreach my $item (@{$item})
#{print "\t$item\n"}
#}
foreach my $item (@Draw){
$valueName = $item;
print "<tr>\n";
print "\t<td>$counter</td>\n";
print "\t<td>$item</td>\n";
print "\t<td><input type='checkbox' name='playedCardsCheckbox'
value='$counter'></td>\n";
print "\t<td><input type='checkbox' name='discardCardsCheckbox'
value='$counter'></td>\n";
print "</tr>\n";
$counter++;
}
print "</table>\n";
print qq{
<table border="1">
<tr>
<th>In Play</th>
<th>In Discard</th>
</tr>
<tr>
<td>Cards in play are listed here</td>
<td>Cards in the discard pile are listed here</td>
</tr>
</table>
};
print qq{
</form>
</body>
</html>
}
_________________________________________________________________
Join the world�s largest e-mail service with MSN Hotmail.
http://www.hotmail.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]