Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re^3: prob w/ gatekeeper subroutine

by Anonymous Monk
on Sep 29, 2010 at 16:45 UTC ( #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.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2020-02-17 13:04 GMT
Find Nodes?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?

    Results (71 votes). Check out past polls.