in reply to Re^3: Perl Script to populate Dropdown box from XML Attributes
in thread Perl Script to populate Dropdown box from XML Attributes

Its not a terminal server. But it has Perl Script on it. "perl -v" on cmd brings up this:

This is perl, v5.6.1 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail)

Copyright 1987-2001, Larry Wall

Binary build 631 provided by ActiveState Tool Corp. http://www.ActiveState.com Built 17:16:22 Jan 2 2002

Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on this system using `man perl' or `perldoc perl'. If you have access to the Internet, point your browser at http://www.perl.com/, the Perl Home Page.

I have gone through the Client-side PerlScript example:

<html> <head> <title>PerlScript Hello World!</title> </head> <body bgcolor="#ffffff"> <h2>PerlScript Hello world!</h2> <script language="PerlScript"> $window->document->write('Hello world!'); </script> </body> </html>

This works with the below meta tag in the <head> section

<html> <head> <meta http-equiv="X-UA-Compatible" content="IE=8" /> <title>PerlScript Hello World!</title> </head> <body bgcolor="#ffffff"> <h2>PerlScript Hello world!</h2> <script language="PerlScript"> $window->document->write('Hello world!'); </script> </body> </html>

The above code works fine but I am asked not to use meta tag work around. And even after using meta tag, my original code is not working.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>demo of dropdown list using xml element data in PerlScript</ti +tle> </head> <body> <SELECT id="STATE" style="WIDTH: 100px; "> <option value="" selected></option> <SCRIPT language="PerlScript"> use strict; use warnings; use feature 'say'; use XML::XPath; my $xp = XML::XPath->new(filename => 'State.xml'); my $querysshh = '/States/State'; $nodeset = $xp->find($querysshh); foreach $mynode ($nodeset->get_nodelist) { my $statenames = $myNode->getAttribute('Name'); print $statenames; $window->document->write("<option value='".$staten +ames."'>".$statenames."</option>"); } </SCRIPT> </SELECT> </body> </html>

We use IE9 & IE11. So used the below code in the <script> tag

HKEY_LOCAL_MACHINE\SOFTWARE\ActiveState\PerlScript\1.0 REG_DWORD: EnabledZones = 0x0010 (default)

Still it did not work. Can you help me to understand the problem with my code better and how to make it work? Thanks!

Replies are listed 'Best First'.
Re^5: Perl Script to populate Dropdown box from XML Attributes
by Corion (Patriarch) on Nov 25, 2016 at 17:40 UTC

    You still need to learn about HTTP and HTML and how they interact.

    The file you want to read here:

    my $xp = XML::XPath->new(filename => 'State.xml');

    will be read on the client, because your code runs on the client.

    But that file doesn't exist on the client, or even if it exists, you also need an absolute path to it that is readable from the client.

    Also, the version of Perl you have "on the client" above is Perl 5.6.1 (reaally ancient), and it does not support use feature 'say';.

    I feel your whole approach is misguided as you could implement all of the above without the reliance on PerlScript by simply producing the appropriate HTML server-side, using XML::XPath and Template::Toolkit for example.

Re^5: Perl Script to populate Dropdown box from XML Attributes
by marto (Cardinal) on Nov 25, 2016 at 17:40 UTC

    I suggest you re read the existing responses you have, explaining why your code doesn't do what you think it should. That's an ancient version of perl and there's a reason why nobody writes code like this (client side perlscript) anymore.

Re^5: Perl Script to populate Dropdown box from XML Attributes
by soonix (Chancellor) on Nov 27, 2016 at 16:22 UTC
    Whichever way you take, you should get a newer Perl version. If that is not yours to do, at least approach the person who updated the Operating System without also updating relevant applications (that META tag you mentioned is about compatibility). Active Perl is at 5.24 meanwhile, the oldest listed on their website is 5.8 - I doubt they still support 5.6…

    The next point is, if you want to do this client side: not only will you need to have the "State.xml" file locally on each client in the appropriate place (which you'll have yet to find out), but you need XML::XPath and probably other modules installed on each client.

    So my recommendation is like the others' - go for server side. But have Perl updated anyway!