Forum Moderators: coopster & phranque

Message Too Old, No Replies

perl cgi printing HTML question

perl cgi printing HTML question

         

StopSpam

9:16 am on Apr 2, 2003 (gmt 0)

10+ Year Member



This i think a simple question
i hope the answer is it to ...

sub print { # print html 1

print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>This is page 1</TITLE></HEAD><BODY BGCOLOR=FFFFFF><CENTER>This is page 1</CENTER></BODY></HTML>";

}
exit;
sub print2 { # print html 2

print "<HTML><HEAD><TITLE>This is page 2</TITLE></HEAD><BODY BGCOLOR=FFFFFF><CENTER>This is page 2</CENTER></BODY></HTML>";

this scripts print out HTML 1 in your browser
and if sub print 2 gets activated it prints this HTML 2 on same page bellow HTML 1 ;-(

why? how can i make it print HTML 2 as new page not below HTML 1.
i used exit;
but that those not help

please advise

thx

ShawnR

10:00 am on Apr 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you still have the problem if you don't call your first sub the same name as a built-in perl function?

Shawn

StopSpam

10:19 am on Apr 2, 2003 (gmt 0)

10+ Year Member



Hi ..

yes have not solved it yet ..

what do you mean with built-in perl function?

ShawnR

10:33 am on Apr 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry for being cryptic. I mean it is not a good idea to have a sub called 'print', as 'print' is a built in perl function. In your sub print2 you call the function 'print'. What do you want to happen? Your previously defined 'print' function, or perl's built in 'print' function?

Shawn

StopSpam

10:58 am on Apr 2, 2003 (gmt 0)

10+ Year Member



i dont think that makes any differance

the above sa,mple is named

sub print and sub print 2
but the realscript use names like;

sub mail then its prints hmtl 1

and sub go prints html 2

but it prints html 2 at bottom of html1
and iwant itto print html 2 as new page not bellow html 1

i dont think it metter if you name it sub print or sub whatever as long sub is in front of it apache knows its not a print tag like

print"

andreasfriedrich

11:28 am on Apr 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is a huge difference between defining a subroutine myprint and print [perldoc.com]. As Shawn already pointed out print [perldoc.com] is a built-in function. You are trying to override that built-in functions. For quite a few functions that is possible by use [perldoc.com]ing subs qw(function1 function2); However, print cannot be overriden.

Apache [httpd.apache.org] does not care nor does it know the slightest thing about Perl [perl.com].

Andreas

StopSpam

11:35 am on Apr 2, 2003 (gmt 0)

10+ Year Member



thank you

i know anough

^_^