It works fine for me both at the command line and browser, and I don't see anything immediately wrong with it. Try turning on warnings and use the strict pragma; those may help describe the problem more closely. Also, be aware if you're only checking the output in a web browser that you haven't actually created an html document per your content-type header. To do that, you need to wrap your output in <html> and preferably <body> tags. Modern browsers won't care, but it wouldn't hurt. A cleaned up version of your code following all that advice might look like this: #!/usr/bin/perl -w
use strict;
my @skuid=("11021","11022","11023");
my @name=("mt. eden","dom perignon","veuve cliquot");
my @price=("45.99","135.99","79.99");
print "Content-type:text/html\n\n";
print "<html><head><title>Test script</title></head><body>\n";
foreach my $skuid (@skuid) {
print "SKUID:$skuid\n";
}
foreach my $name (@name) {
print "NAME:$name\n";
}
foreach my $price (@price){
print "PRICE:$price\n";
}
print "</body></html>";
As an aside, be inclined to use the CGI.pm module rather than manual html if you're planning on doing more serious CGI work in the future.If none of this helps, more information on your platform, perl version (with perl -v), and browser would be helpful. Update: I just couldn't help myself... the problem I think you're trying to solve screams for a hash. Here's how I would actually do it (note I'm a big fan of using CGI.pm functionally): #!/usr/bin/perl -w
use strict;
use CGI ":standard";
my %wines = (11021 => ["Mt. Eden", "45.99"],
11022 => ["Dom Perignon", "135.99"],
11023 => ["Veuve Cliquot", "49.99"]);
print header, start_html({-title=>'Wines'}),
table({-border=>1},
[Tr([th(["SKUID",
"Name",
"Price"
]),
map td([$_,
$wines{$_}->[0],
$wines{$_}->[1]]),
sort keys %wines
])
]),
end_html;
|