Insert JavaScript into Perl

A

alex.osinski

I have a site running off Perl. I know nothing of Perl and have been
told to insert our standard intranet header and footer. (ack!) Our
header and footer are included into our pages via:

<script language="javascript"
src="/GlobalInsideITNew/JS/InsideITGlobalHeader.js"></script>

&

<script language="javascript"
src="/GlobalInsideITNew/JS/InsideITGlobalFooter.js"></script>

When I try to insert this code into the Perl run site, it never shows
up. This is the syntax I'm using for the header:

print FILE"<SCRIPT language=\"JavaScript\"
src=\"/GlobalInsideITNew/JS/InsideITGlobalHeader.js\"> \n";
print FILE"</SCRIPT> \n";

Help! What am I doing wrong?
 
X

xhoster

I have a site running off Perl. I know nothing of Perl and have been
told to insert our standard intranet header and footer. (ack!)

Why do you have a site running off Perl if you know nothing about
Perl?
Our
header and footer are included into our pages via:

<script language="javascript"
src="/GlobalInsideITNew/JS/InsideITGlobalHeader.js"></script>

I know little about javascript, but doesn't this just cause a js library
to be loaded without actually running anything in that library?
&

<script language="javascript"
src="/GlobalInsideITNew/JS/InsideITGlobalFooter.js"></script>

When I try to insert this code into the Perl run site, it never shows
up.

Never shows up where?
This is the syntax I'm using for the header:

Well, that might be the first problem. What is this header you talk
about?
print FILE"<SCRIPT language=\"JavaScript\"
src=\"/GlobalInsideITNew/JS/InsideITGlobalHeader.js\"> \n";
print FILE"</SCRIPT> \n";

Why are you printing to FILE? Is FILE even open? In Perl CGI (or isn't
this even CGI?), the handle you print html to us generally STDOUT, not
FILE.

Perl has a great thing called "here-docs" which let you print literal
text, such as javascript, with a lot less backwhacking and other
punctuation.


print <<'EOS';
<script language="javascript"
Help! What am I doing wrong?

There are so many possibilities, and you haven't given us enough to
go on.

Xho
 
C

cassiux

I've been told to add this header, I don't actually RUN the site. The
usual admin is out for a week.

I guess this is Perl CGI. Keep in mind this is all new to me.

I could be printing to a kangaroo in perl and not know the difference,
I just found print FILE off the net.

I tried your "here-docs" code w/out success. The page runs and it
never shows up. I'll research Perl tonight and see what the deal is.
Damn. Thanks though.
 
X

xhoster

cassiux said:
I've been told to add this header, I don't actually RUN the site. The
usual admin is out for a week.

Hmmm, I think this is what we call an "unenviable position". Bummer.
I guess this is Perl CGI. Keep in mind this is all new to me.

I could be printing to a kangaroo in perl and not know the difference,
I just found print FILE off the net.

Look for other print statements in the program which you are modifying,
and see if they have "FILE" (or some other file handle) on them.
I tried your "here-docs" code w/out success. The page runs and it
never shows up. I'll research Perl tonight and see what the deal is.
Damn. Thanks though.

Are you looking for it in the html source, or just the rendered page?
Maybe it is there, but not in a position to actually do anything.
Maybe try something less subtle first, like:

print "<H1>Hey diddle diddle the cat played the fiddle</H1>\n";

And see if *that* shows up.


Or show us a few lines of context surrounding the place where you think
the print belongs, and maybe we can give tell you why it should or should
not.

Xho
 
S

Scott Bryce

I have a site running off Perl.

You probably have a site made up of web pages that are generated by CGI
scripts written in Perl.
I know nothing of Perl and have been
told to insert our standard intranet header and footer.

Not a fun place to be.
(ack!) Our
header and footer are included into our pages via:

<script language="javascript"
src="/GlobalInsideITNew/JS/InsideITGlobalHeader.js"></script>

&

<script language="javascript"
src="/GlobalInsideITNew/JS/InsideITGlobalFooter.js"></script>

When I try to insert this code into the Perl run site,

What you probably want to do is insert the code into the HTML stream
that the CGI script is sending to the browser.
it never shows
up. This is the syntax I'm using for the header:

print FILE"<SCRIPT language=\"JavaScript\"
src=\"/GlobalInsideITNew/JS/InsideITGlobalHeader.js\"> \n";
print FILE"</SCRIPT> \n";

Help! What am I doing wrong?

We can only guess. Try something that looks more like:

print qq(<script language="javascript"
src="/GlobalInsideITNew/JS/InsideITGlobalHeader.js"></script>\n);
 
L

Leon

I have a site running off Perl. I know nothing of Perl and have been
told to insert our standard intranet header and footer. (ack!) Our
header and footer are included into our pages via:

<script language="javascript"
src="/GlobalInsideITNew/JS/InsideITGlobalHeader.js"></script>

&

<script language="javascript"
src="/GlobalInsideITNew/JS/InsideITGlobalFooter.js"></script>

When I try to insert this code into the Perl run site, it never shows
up. This is the syntax I'm using for the header:

print FILE"<SCRIPT language=\"JavaScript\"
src=\"/GlobalInsideITNew/JS/InsideITGlobalHeader.js\"> \n";
print FILE"</SCRIPT> \n";

Help! What am I doing wrong?

Been mentioned already, but I'd always go for the trouble free option...

print <<EndOfHTML;
<script language="javascript"
src="/GlobalInsideITNew/JS/InsideITGlobalHeader.js"></script>
EndOfHTML

print <<EndOfHTML;
<script language="javascript"
src="/GlobalInsideITNew/JS/InsideITGlobalFooter.js"></script>

EndOfHTML

Always ensure that there are absolutely no spaces following the closing
EndOfHTML line.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,164
Messages
2,570,898
Members
47,439
Latest member
shasuze

Latest Threads

Top