I've been having trouble with something that seems simple, but has kept me stumped for a couple of days. Heads up: I'm not a professional programmer. I'm very familiar with the book Learning Perl but largely foggy with Intermediate Perl.
My frustration is with getting newlines to work. The following code isolates my problem:
Code:
#!/usr/bin/perl
# trial.cgi
my $query = "student_id=triplett-1&submitButtonName=REGISTER";
my @name_value_pairs = split /&/, $query;
print "Content-type: text/html\n\n";
print "$name_value_pairs[0]\n";
print "$name_value_pairs[1]\n";
print;
foreach my $pair (@name_value_pairs){
print "$pair\n";
}
print $name_value_pairs[0];
print;
print;
print $name_value_pairs[1];
die "$query";
exit;
The first PRINT ends with two newlines as it should, and the server balks without them. This is as expected. But the remaining newlines appear on my browser as spaces for some reason, instead of on separate lines. Below is a copy/paste from my browser screen:
Quote:
|
student_id=triplett-1 submitButtonName=REGISTER student_id=triplett-1 submitButtonName=REGISTER student_id=triplett-1submitButtonName=REGISTER
|
Also, I've tried replacing PRINT with SAY, but it won't compile. Maybe the version of the installed Perl?
Any comments/guesses will be most welcome!
Rick