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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subroutine Question. 1

Status
Not open for further replies.

perlone

Programmer
Joined
May 20, 2001
Messages
438
Location
US
Hi,

Most of the pages I use has to do with subs. I have a page like this:

if ($mode eq "view") {
&header(qq~
#somehtml
~,"Page Title");
exit;
}

but i want to add some perl code inside the (#somehtml) part. Like the "EOF" function. Any idea how do i do this?

Here's an example of what i'm talking about if i didn't used 'subroutines'.

print <<EOF;
#somehtml
EOF
#perl code

print <<EOF;
#continue html
EOF

I want to do the code like above but how do I add that to the header() subroutine? Thanks again for your time.

-Aaron
 
One way is like this:
Code:
if ($mode eq &quot;view&quot;) {
$myhtml = <<END;
#some html
#some more html
END
&header($myhtml,&quot;Page Title&quot;);
exit;
}
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Thanks, i'll try that. -Aaron
 
I have one more question though. Let's say i'm doing this:

&header(qq~
#HTML PART
#But I want to add some perl right here. is this possible?
#MORE HTML
~,&quot;Title Page&quot;);
exit; -Aaron
 
Unfortunately, it's not possible to do it that way. There are probably ways around it though. You can add variables there, but not code. Using the method I showed above you can do it, but building part of the header. Then executing some perl, then concatenating more html onto the header. Would that work?

There are also ways to interpolate subroutine calls into variables. That might be a way to do what you want. I'd have to check how to manage that.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Thanks, i might try to save all the html files in html.cgi and call it by using the require &quot;html.cgi&quot; function. -Aaron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top