Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Is script type="text/perl" OK?

Reply
Thread Tools

Is script type="text/perl" OK?

 
 
lg
Guest
Posts: n/a
 
      01-14-2008
I've asked this on a html forum but I'll ask it here also.

I have a counter file on my index page which is like below.
Snippet from index.html:
<script type="text/perl" SRC="http://www.blahblah.com/counter.pl"> </script>

The script is is a perl file which is processed by the server. Is it legal? Will
my counter work (be run as usual)?

Below runs OK too, but I get a "done, but with errors on the page"
<script type="text/javascript" SRC="http://www.blahblah.com/counter.pl">
</script>

What I am trying to do is get rid of the error message and have the counter.pl
execute. Since the server (not the client browser) is doing the running of the
counter.pl I want to know if "<script type="text/perl" SRC="http://.." is
otherwise valid. I could just put the line there and see if I get hits, but I
don't want to find out six months later that it while it does work on many
browsers it does not work on not-so-common-browser and the browser simply quits
interpreting the html on the file and issues a 404 or similar message.
 
Reply With Quote
 
 
 
 
Joost Diepenmaat
Guest
Posts: n/a
 
      01-14-2008
lg <(E-Mail Removed)> writes:

> I've asked this on a html forum but I'll ask it here also.
>
> I have a counter file on my index page which is like below.
> Snippet from index.html:
> <script type="text/perl" SRC="http://www.blahblah.com/counter.pl"> </script>
>
> The script is is a perl file which is processed by the server. Is it
> legal?


Yes. But then your script is expected to return perl code to the
browser. But unless your script actually returns valid perl and your
browser has a perl scripting plugin (like the ActivePerl PerlScript plugin)
this is probably not what you want.

Note: the <script> tag indicates that whatever is sent *to the browser*
is to be run as a script. There is way and no need to indicate that
something is *generated by a script* on the server side.

> Will my counter work (be run as usual)?


Maybe, probably not. I would expect browsers to just ignore (i.e. not
fetch the URL for) script tags with types they can't understand, but I
haven't tested this. If that's true, the only type that's anywhere near
universally supported is javascript. Personally, I'd use an <img> tag
instead.

> Below runs OK too, but I get a "done, but with errors on the page"
> <script type="text/javascript" SRC="http://www.blahblah.com/counter.pl">
> </script>


That's probably because your script does not return valid javascript.

> What I am trying to do is get rid of the error message and have the counter.pl
> execute. Since the server (not the client browser) is doing the running of the
> counter.pl I want to know if "<script type="text/perl" SRC="http://.." is
> otherwise valid. I could just put the line there and see if I get hits, but I
> don't want to find out six months later that it while it does work on many
> browsers it does not work on not-so-common-browser and the browser simply quits
> interpreting the html on the file and issues a 404 or similar message.


Some people, like me, have browser scripting disabled, so it won't work
any way. Most counter scripts I've seen are called using an <img>
tag. Whatever you use, just make sure you send back the right kind of
response; an image for an <img> tag, a (javascript) script for a
<script> tag etc. Or maybe a 204 NO RESPONSE result will work.

Joost.
 
Reply With Quote
 
 
 
 
lg
Guest
Posts: n/a
 
      01-14-2008
Joost Diepenmaat <(E-Mail Removed)> wrote:

>lg <(E-Mail Removed)> writes:
>
>> I've asked this on a html forum but I'll ask it here also.
>>
>> I have a counter file on my index page which is like below.
>> Snippet from index.html:
>> <script type="text/perl" SRC="http://www.blahblah.com/counter.pl"> </script>
>>
>> The script is is a perl file which is processed by the server. Is it
>> legal?

>
>Yes. But then your script is expected to return perl code to the
>browser. But unless your script actually returns valid perl and your
>browser has a perl scripting plugin (like the ActivePerl PerlScript plugin)
>this is probably not what you want.
>
>Note: the <script> tag indicates that whatever is sent *to the browser*
>is to be run as a script. There is way and no need to indicate that
>something is *generated by a script* on the server side.
>
>> Will my counter work (be run as usual)?

>
>Maybe, probably not. I would expect browsers to just ignore (i.e. not
>fetch the URL for) script tags with types they can't understand, but I
>haven't tested this. If that's true, the only type that's anywhere near
>universally supported is javascript. Personally, I'd use an <img> tag
>instead.
>
>> Below runs OK too, but I get a "done, but with errors on the page"
>> <script type="text/javascript" SRC="http://www.blahblah.com/counter.pl">
>> </script>

>
>That's probably because your script does not return valid javascript.
>
>> What I am trying to do is get rid of the error message and have the counter.pl
>> execute. Since the server (not the client browser) is doing the running of the
>> counter.pl I want to know if "<script type="text/perl" SRC="http://.." is
>> otherwise valid. I could just put the line there and see if I get hits, but I
>> don't want to find out six months later that it while it does work on many
>> browsers it does not work on not-so-common-browser and the browser simply quits
>> interpreting the html on the file and issues a 404 or similar message.

>
>Some people, like me, have browser scripting disabled, so it won't work
>any way. Most counter scripts I've seen are called using an <img>
>tag. Whatever you use, just make sure you send back the right kind of
>response; an image for an <img> tag, a (javascript) script for a
><script> tag etc. Or maybe a 204 NO RESPONSE result will work.


How would I do it with <IMG> tag


>
>Joost.

 
Reply With Quote
 
Joost Diepenmaat
Guest
Posts: n/a
 
      01-14-2008
lg <(E-Mail Removed)> writes:
> How would I do it with <IMG> tag


<img src="url-to-some-script-that-returns-an-image">

#!perl -w
use strict;
print "Content-type: image/png\n\n";
binmode STDOUT;
print $string_containing_png_data;

--
Joost.
 
Reply With Quote
 
smallpond
Guest
Posts: n/a
 
      01-14-2008
On Jan 14, 6:50 am, lg <(E-Mail Removed)> wrote:
> I've asked this on a html forum but I'll ask it here also.
>
> I have a counter file on my index page which is like below.
> Snippet from index.html:
> <script type="text/perl" SRC="http://www.blahblah.com/counter.pl"> </script>
>
> The script is is a perl file which is processed by the server. Is it legal? Will
> my counter work (be run as usual)?
>
> Below runs OK too, but I get a "done, but with errors on the page"
> <script type="text/javascript" SRC="http://www.blahblah.com/counter.pl">
> </script>
>
> What I am trying to do is get rid of the error message and have the counter.pl
> execute. Since the server (not the client browser) is doing the running of the
> counter.pl I want to know if "<script type="text/perl" SRC="http://.." is
> otherwise valid. I could just put the line there and see if I get hits, but I
> don't want to find out six months later that it while it does work on many
> browsers it does not work on not-so-common-browser and the browser simply quits
> interpreting the html on the file and issues a 404 or similar message.



If you want the perl code to run on the server and include its output
in
the page sent to the browser, then you need to make a server-side
include (SSI).

<!--#include virtual="/cgi-bin/counter.pl" -->

You will also have to enable SSI on the web server and name the file
index.shtml instead of index.html.
--S
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute a script from another script and other script does notdo busy wait. Rajat Python 3 01-08-2010 02:05 PM
RE: How to execute a script from another script and other script doesnotdo busy wait. VYAS ASHISH M-NTB837 Python 2 01-07-2010 08:18 PM
<script>alert();</script> =?Utf-8?B?PHNjcmlwdD5hbGVydCgpOzwvc2NyaXB0Pg==?= alert Microsoft Certification 0 04-13-2004 06:36 AM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM
How to make Perl Script "POST" call from another Perl Script??? Wet Basement Perl 1 07-15-2003 10:25 PM



Advertisments