Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SSI call returning 1 4

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
I have this SSI call in an index page.
Code:
<!--#include virtual="cgi-bin/picture.pl?call=body&amp;page=home&amp;" -->

It returns the index page's <body> via this print statement.

Code:
	print "<body class='page_body' style='background-image: url(\"images/themes/halloween/homeback.jpg\");'>";

The body statement works fine but there is a stray '1' at the end of the <body> code and this appears at the top of the resulting page.
Is the problem because the script is not returning visible content or is there some other cause?

Keith
 
The problem was a sill schoolboy error.

Menu item .........
Code:
#--------------------------------------------------------
if($INP eq 'body'){
#--------------------------------------------------------
	print &MakeBody();
	exit;
}

calling the sub ..........

Code:
# --------------------------------------------------------
sub MakeBody{
# --------------------------------------------------------
	print "<body class='page_body' style='background-image: url(\"images/themes/halloween/homeback.jpg\");'>";
}

Doh!

Keith
 
Ah double print!

One in the routine, then the 'true' return value from sub.

Just a side note: It is apparently now bad practice to use ampersands for sub calls!

MakeBody();

instead of

&MakeBody();




"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
I use the ampersand on sub calls for clarity and wonder what the issue is with them.

I did a quick search but couldn't find a specific reason not to use them.
Perhaps if I stopped using them, all my code would be perfect and I would never have to spend time looking for errors, ever again.

Keith
 
>> Perhaps if I stopped using them, all my code would be perfect and I would never have to spend time looking for errors, ever again.

Keith wake up - you appear to have nodded off and started dreaming! [sleeping2]

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
Hi

The best hint I found related to this is related to prototypes [sup](*)[/sup] :
man perlsub said:
The function declaration must be visible at compile time. The prototype affects only interpretation of new-style calls to the function, where new-style is defined as not using the & character. In other words, if you call it like a built-in function, then it behaves like a built-in function. If you call it like an old-fashioned subroutine, then it behaves like an old-fashioned subroutine.
( man perlsub | Prototypes | 3[sup]rd[/sup] paragraph )

Personally I keep using the ampersand.

[small](*) The articles I read used various adjectives on them, usually somewhere between pointless and evil.[/small]


Feherke.
feherke.ga
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top