CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Can't get Perl script to work in CGI

 



AndrewG
stranger

Jun 11, 2001, 3:39 PM

Post #1 of 2 (1330 views)
Can't get Perl script to work in CGI Can't Post

I wrote this perl program that parses through comma seperated data. It works fine on the command line. I would like to make it work in CGI so that I can just cut and paste my data into a form. I'm stuck and don't know where to continue. Any help would be appreciated. Thanks.


#!/usr/bin/perl

$row = 1;

while ( <> ) {
@line = split(/,/);
if ($row == 1) {
printf "%-2.2s%-15.15s\n", $line[0], $line[1];
}
if ($row >= 2) {
printf "%-2.2s%-9.9s\n", $line[21], $line[22];
}
else {
$row++;
}
}



randor
User

Jun 11, 2001, 5:54 PM

Post #2 of 2 (1328 views)
Re: Can't get Perl script to work in CGI [In reply to] Can't Post

AndrewG,

try this:

#!/usr/bin/perl

print "Content-type: text/html\n\n";

$row = 1;

while ( <> ) {
@line = split(/,/);
if ($row == 1) {
print "%-2.2s%-15.15s\n", $line[0], $line[1];
}
if ($row >= 2) {
print "%-2.2s%-9.9s\n", $line[21], $line[22];
}
else {
$row++;
}
}


I Hope this helps...

perl programmers don't die.. they just start writing a new script.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives