Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Problem to include a perl file

by hacker (Priest)
on Oct 10, 2003 at 13:17 UTC ( [id://298243]=note: print w/replies, xml ) Need Help??


in reply to Problem to includ a perl file

There is no spoon.

Seriously though, JavaScript is parsed, not executed (similar to perl, but not). You have to provide a link to an actual file containing JavaScript commands that your browser's JavaScript parsing engine can understand and properly parse. Passing it a Perl script will do nothing, except cause the internal browser JavaScript parser to silently abort with an error (unless you have a browser with a JavaScript debugging console). The browser's internal JavaScript parsing engine doesn't understand how to properly parse perl constructs (thankfully), and leaves it alone.

Also, even if that could work, your perl script is redundant, since you're already passing a Content-Type when your webserver sends the .html page to the client, and you then parse a perl script which passes it again, right in the middle of existing content.

In short, use the Perl interpretor to interpret perl, and the JavaScript interpretor to interpret JavaScript.

How about using this instead, less code, easier to maintain:

#!/usr/bin/perl use strict; # ALWAYS use strict use CGI qw(p br); my $cgi = CGI->new(); print $cgi->header(); print $cgi->start_html(-title=>'Welcome'), "\n"; print p('Acesta este pagina de index si mai jos se afla legatura facuta la test.pl'); print p('Acesta este continutul fisierului'), br(); print $cgi->end_html();

You could also do this all in one print statement, if you wish:

#!/usr/bin/perl use strict; # ALWAYS use strict use CGI qw(p br); my $cgi = CGI->new(); print $cgi->header(), $cgi->start_html(-title=>'Welcome'), "\n", p('Acesta este pagina de index si mai jos se afla legatura facuta la test.pl'), p('Acesta este continutul fisierului'), br(). $cgi->end_html();

TMTOWTDI

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://298243]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-19 05:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found