Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Perl & IE

by gjb (Vicar)
on Apr 08, 2004 at 19:39 UTC ( #343723=perlmeditation: print w/ replies, xml ) Need Help??

Yesterday dragonchild wondered about the possibility to use Microsoft Internet Exploren as the user interface layer for client side Perl applications. I remembered vaguely that this was indeed possible and decided to check.

The answer is that you can actually perform client side Perl scripts in Internet Explorer using ActiveState's Perl. Part of the installation is PerlScript, an ActiveX component that ties in with Windows Scripting Host. Once installed, Perl scripts embedded in HTML with the <script> tag are executed in the browser just as JavaScript is.

The following is a simple example that shows the basics:

<html> <head> <title>Test</title> </head> <body> <script language="PerlScript"> $window->document->write("<h2>Table of factorials</h2>\n"); for ($i = 1, $fact = 1; $i <= 10; $i++, $fact *= $i) { $window->document->write("$i! = $fact<br>\n"); } </script> </body> </html>
As you can guess, this example was adapted from the JavaScript rinocerus book (p. 7 in the 3rd edition, O'Reilly). So provided you know the object model, you can do in PerlScript whatever you can in JavaScript. Now honestly I've only dabbled just a little bit in client side scripting, so I'm not going into useful things here. And yes, it's possible to load and use modules.

The reason I've always been slightly suspicious of PerlScript is shown in the following example:

<html> <head> <title>Test</title> </head> <body> <script language="PerlScript"> open(OUT, ">c:/Perl/perlscript.txt"); print OUT "Oh yes!\n"; close(OUT); </script> </body> </html>
Yes, this actually works when the page is loaded from a local disk. Since this is creepy, I checked whether this works when the HTML file is loaded from a webserver and fortunately it doesn't. It seems that PerlScript is subject to the same limitations as JavaScript. Whether this is a reassurance given Microsoft track record on security I'll leave to you to decide.

However, it is tempting to use PerlScript for client side scripting. If you can live with HTLM UI limitations and don't get nuts by keeping track of the state of your application it seems like a viable approach.

For the record, my setup: Windows XP Pro, IE 6, ActiveState Perl 5.8.3.809.

Just my 2 cents, -gjb-

Comment on Perl & IE
Select or Download Code
Re: Perl & IE
by BUU (Prior) on Apr 08, 2004 at 21:49 UTC
    Yeah, but now you're writing IE only code and that ain't cool.
      The point is that this code is living on the client machine. This isn't server code. This is code that's distributed in the old model, by downloading and installing. Hence, if only Win32 machines d/l it, there's no problem.

      ------
      We are the carpenters and bricklayers of the Information Age.

      Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://343723]
Approved by herveus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2014-08-20 13:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (114 votes), past polls