Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: prob w/ gatekeeper subroutine

by Anonymous Monk
on Sep 29, 2010 at 16:45 UTC ( [id://862655]=note: print w/replies, xml ) Need Help??


in reply to Re^2: prob w/ gatekeeper subroutine
in thread prob w/ gatekeeper subroutine

(The error regarding the check for numerical vs. string equality has been pointed out and was not contained in your original post, so I ignore it in my response.)

I believe you are encountering a variable scoping issue. Make sure your hash contents are visible to the subroutine (which they aren't unless you assign the correct global scope to the hash variable). The following declaration of the hash inside a naked block will throw an error as the hash is unknown to the subroutine.
#! /usr/bin/perl -w use strict; { our %hash; $hash{ 1 } = "OK"; &routine; } sub routine { print $hash{ 1 }; }

Hope this helps.
Pat

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-20 01:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found