Unknown wrote:

Our problem is the original authors of the code assumed variables are
not globally scoped.

You mean one of the original authors doesn't understand Perl.

Q1.1: How come in other languages, the scope of the variable is
assumed to be for the page unless
defined otherwise (e.g. PHP, ActivePerl, VBScript)?

First, drop ActivePerl from that. That's a different issue entirely. Second, the reason has to do with Perl's history, but it's really not important to argue about it here -- do that on comp.lang.perl.misc.


As for ActivePerl, that's a red herring. ActivePerl is the same language as used by Apache::ASP, so the variable scoping behaves the same way. The real issue is mod_perl vs. whatever persistent interpreter mechanism ActivePerl uses under IIS. The Perl interpreter is running in a different way in each environment, and that's the source of the difference in behavior. This is not Apache::ASP's fault. It's just a portability issue you will have to cope with.

Q1.2: Is there a configuration option or easy way around this issue?

Rewrite the code so that it doesn't use global variables. This is a good idea in any case. Turn on the "use strict" pragma, and Perl will refuse to run your scripts until you either explicitly make all variables global, or make them lexically scoped.


Q2.1: Since this sub is included in sample.asp, is it considered a
subroutine within a subroutine?

Yes. Put it in a Perl module instead, and either "use MyModule" from each ASP file that needs the routine, or "use" the module in global.asa.


The main downside of this is that you will have to restart Apache each time you change one of the Perl modules, since Apache::ASP won't recompile the scripts when a module changes.

Q2.2: Is there an easy way to convert include.asp to include.pm so I
can use "use include.pm" in our scripts?

The 'use MyModule' syntax should work just fine in both ASP implementations. It's a Perl language issue, and as I've pointed out, the language interpreter is the same in both cases.


This is not a complete replacement for #include. The Perl module method works only for Perl code. If you want a pure textual include, there's $Response->Include(), but you still don't want to put subroutines in the included file.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to