Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

problem with strict in perl 5.6 and asp

by grashoper (Monk)
on Nov 04, 2007 at 17:35 UTC ( #648892=perlquestion: print w/ replies, xml ) Need Help??
grashoper has asked for the wisdom of the Perl Monks concerning the following question:

I experience the following problem when using strict with perl 5.6 and asp, it complains about built in windows objects like $request and $session variables not being declared in my existing code, I know they exist because they are objects in iis and I can read their values without a problem I tried using the asp module but it still complains has anyone encountered this problem before? I tried using data dumper but I must be doing something wrong as it doesn't shed any light on what is wrong I get the same error no additional output. I really need strict as I am a beginner.

Comment on problem with strict in perl 5.6 and asp
Re: problem with strict in perl 5.6 and asp
by erroneousBollock (Curate) on Nov 04, 2007 at 18:23 UTC
    I experience the following problem when using strict with perl 5.6 and asp
    Right, so are you using PerlScript or Apache::ASP?

    it complains about built in windows objects like $request and $session variables not being declared in my existing code, I know they exist because they are objects in iis and I can read their values without a problem
    Ok, you're using PerlScript. How does it complain?; tell us the exact errors you're getting. How did you verify those objects exist? Because you tested with another language? What aren't you telling us about your application setup?

    I tried using the asp module but it still complains has anyone encountered this problem before?
    I'm not sure about PerlScript, but with Apache::ASP you need to use the capitalised object names (eg: $Request, $Response, $Application, etc). Perl is a case-sensitive language (unlike VBScript).

    I really need strict as I am a beginner
    Absolutely... unless you've got a really good reason to turn off the 'strict' and 'warnings' pragams, always use them. And if you already know a reason, it's wrong ;)

    -David

      David using perlscript activestate 5.6 on one box and 5.8 on my test box, I pasted my errors. Tried data dumper but I am not sure I did it correctly. I just put use data::dumper; in my file, I tried the object tag too like their example in the readme neither seemed to change anything.
      Global symbol "$Request" requires explicit package name at (eval 2) li +ne 35. Global symbol "$Session" requires explicit package name at (ev +al 2) line 37. Global symbol "$Session" requires explicit package nam +e at (eval 2) line 51. Global symbol "$Session" requires explicit pac +kage name at (eval 2) line 53. Global symbol "$Response" requires exp +licit package name at (eval 2) line 54. Global symbol "$Session" requ +ires explicit package name at (eval 2) line 54. Global symbol "$Sessi +on" requires explicit package name at (eval 2) line 56. Global symbol + "$Request" requires explicit package name at (eval 2) line 56. Globa +l symbol "$Session" requires explicit package name at (eval 2) line 5 +8. Global symbol "$Session" requires explicit package name at (eval 2 +) line 59. Global symbol "$Session" requires explicit package name at + (eval 2) line 60. Global symbol "$Session" requires explicit package + name at (eval 2) line 62. Global symbol "$Session" requires explicit + package name at (eval 2) line 62. Global symbol "$Session" requires +explicit package name at (eval 2) line 62. Global symbol "$Request" r +equires explicit package name at (eval 2) line 64. Global symbol "$Re +quest" requires explicit package name at (eval 2) line 64. Global sym +bol "$Session" requires explicit package name at (eval 2) line 68. Gl +obal symbol "$Session" requires explicit package name at (eval 2) lin +e 68. Global symbol "$Session" requires explicit package name at (eva +l 2) line 68. (in cleanup) BEGIN not safe after errors--compilation a +borted
      on my 5.6.1 box I get the same.
      PerlScript Error error '80004005' Global symbol "$Request" requires explicit package name at (eval 2) li +ne 34. Global symbol "$Session" requires explicit package name at (ev +al 2) line 36. Global symbol "$Session" requires explicit package nam +e at (eval 2) line 50. Global symbol "$Session" requires explicit pac +kage name at (eval 2) line 52. Global symbol "$Response" requires exp +licit package name at (eval 2) line 53. Global symbol "$Session" requ +ires explicit package name at (eval 2) line 53. Global symbol "$Sessi +on" requires explicit package name at (eval 2) line 55. Global symbol + "$Request" requires explicit package name at (eval 2) line 55. Globa +l symbol "$Session" requires explicit package name at (eval 2) line 5 +7. Global symbol "$Session" requires explicit package name at (eval 2 +) line 58. Global symbol "$Session" requires explicit package name at + (eval 2) line 59. Global symbol "$Session" requires explicit package + name at (eval 2) line 61. Global symbol "$Session" requires explicit + package name at (eval 2) line 61. Global symbol "$Session" requires +explicit package name at (eval 2) line 61. Global symbol "$Request" r +equires explicit package name at (eval 2) line 63. Global symbol "$Re +quest" requires explicit package name at (eval 2) line 63. Global sym +bol "$Session" requires explicit package name at (eval 2) line 67. Gl +obal symbol "$Session" requires explicit package name at (eval 2) lin +e 67. Global symbol "$Session" requires explicit package name at (eva +l 2) line 67. (in cleanup) BEGIN not safe after errors--compilation a +borted /base/base.asp, line 29
      David how seriously bad is it to use no strict "vars"; my existing code makes heavy use of built in variables like $Response, $Session, and $Request. If its really bad practice or not recommended obviously I don't want to do it that way. Thanks.. Monty

        Can't you just declare the (not quite) "built-in" variables with our?

        use strict; # with impunity our( $Response, $Session, $Request );

        (our should be usable with 5.6 and later; otherwise the vars pragma could be an alternative.)

        print "Just another Perl ${\(trickster and hacker)},"
        The Sidhekin proves Sidhe did it!

Re: problem with strict in perl 5.6 and asp
by erroneousBollock (Curate) on Nov 05, 2007 at 14:11 UTC
    Ok, new tack.

    Are you using the <%@ PerlScript%> syntax or the <SCRIPT LANGUAGE="PerlScript" RUNAT=Server> syntax to embed PerlScript?

    Or better still... how does the following example script work for you?

    <%@ LANGUAGE="VBScript" %> <HTML> <HEAD> <% Sub InlineSub %> This text won't be displayed until this subroutine is called.<br +> <% End Sub %> <SCRIPT LANGUAGE="VBScript" RUNAT=SERVER> 'Immediate script (outside a function). Response.Write "This text is displayed last" </SCRIPT> <SCRIPT LANGUAGE="JavaScript" RUNAT=SERVER> function TestJavaScript(str) { Response.Write(str); } </SCRIPT> <SCRIPT LANGUAGE="PerlScript" RUNAT=SERVER> sub TestPerlScript { $Response->Write($_[0]); } </SCRIPT> </HEAD> <BODY BGCOLOR=#FFFFFF> <% Response.Write "This is VBScript<br>" TestJavaScript "This is JavaScript<br>" TestPerlScript "This is PerlScript<br>" InlineSub %> </BODY> </HTML>
    If that doesn't work as-is, I'd say you've an installation issue.

    -David

      That script works fine. I can't figure where this "bareword remove" and "bareword cancel" are coming from.
        I have a vague memory that there's something weird about the way PerlScript embeds perl in ASP w.r.t package variables.

        If I remember correctly, sometimes you need to pass $Request, $Application, etc to your subroutines instead of referencing them within the subroutines. I know that sounds crazy, but I seem to remember that solving quite a few issues.

        Update: Aha! I remembered correctly. That link explains how to 'use strict' successfully in PerlScript.

        -David

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (13)
As of 2014-07-25 17:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (174 votes), past polls