made_in_india
made_in_india

Reputation: 2279

Cgi script is printing the html text file rather rendering it in the browser while sourcing the module

I have following code

#file 1 a.pm
package a;
@Export=(test);

print "test"; #hashing this is enabling the rendering 

sub test {
  return 1;
} 

#file 2 main cgi script test.pl
use a;
my $t = test();
print "Content-type: text/html\n\n";
print "<html>\n<body>\n<p>test= $t</p></body>\n</html>";

While hashing the print line in module a is enabling the rendering but when print statement is enable, it is unable to do it?

Upvotes: 0

Views: 568

Answers (1)

Michael Krelin - hacker
Michael Krelin - hacker

Reputation: 143061

When you use the a module, the print "test" is executed. i.e. test is printed before the Content-type header. Furthermore, your Content-type header turns into testContent-type.

Upvotes: 1

Related Questions