#1 (permalink)  
Old 03-11-2005, 08:39 PM
Registered User
 
Join Date: Mar 2005
Posts: 2
Unhappy Newb needs help with parsing an array into html output

All I want to do is take a single input from a form, which will probably be a very long string with values separated by commas or line breaks, presumably split that string into an array of values, then drop in those values in the appropriate places in an HTML formatted output to the browser. I've done this with individual form field inputs, but I've never worked with arrays, so I'm certain that's where my script is dying. I can't telnet into my account and run the script from the command line, but I did direct the error to the browser and it's having compilation errors (how helpful). I'll include my code below, but I'm sure it's just my basic lack of understanding how to work with arrays. Being a complete newb to this, I'd like replied to include actual code snippets that I can copy and paste, rather than "oh, just split the array and then reassign the values to a list" or some other greek to this geek. What's the key ingredient(s) that I'm obviously missing?

Thanks!
-Greg

Code:
#!/usr/bin/perl
use CGI::Carp qw( fatalsToBrowser );
open (STDERR, ">&STDOUT");

# Receive Info
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

# Process Info

@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
	($name, $value) = split(/=/, $pair);
	$value =~ tr/+/ /;
	$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
	$value =~ s/<!--(.|\n)*-->//g;
	$value =~ s/<([^>]|\n)*>//g;
	$INPUT{$name} = $value;
}

$exportedscores = $input{'exportedscores'};

# split the input into an array
@scoredata = split(/\n/, $exportedscores);

#Show user the Scoresheet...
print <<EOM;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>ALTC Game Score: </title></head>
<LINK REL=StyleSheet HREF="/ltag/scoresheets.css" TYPE="text/css" TITLE="Preferred Style"></HEAD>
<body>

<P>
Overall game score: @scoredata[1]<BR>
Player 1 Score: @scoredata[5]<BR>
Team 1 Rank: @scoredata[7]<BR>
</P>

</body>
</html>

EOM
exit;
}
Reply With Quote

  #2 (permalink)  
Old 03-20-2005, 06:39 PM
Registered User
 
Join Date: Mar 2005
Posts: 2
Anyone?
...
Anyone?
...
Bueller?
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -5. The time now is 04:33 PM.

 
Bitrix
Clicky Web Analytics
CloudContacts
Maxtango


Subscribe to our feed | add to myYahoo!

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
© 1997-2007 HTMLCenter