Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Scope of a Hash

by secret (Beadle)
on Dec 15, 2005 at 16:06 UTC ( #517001=note: print w/replies, xml ) Need Help??

in reply to Scope of a Hash

I call a subroutine &createExcelChart that passes the hash in as *returnVals.

AAaaah !!! Why do you do this ??
Don't use typeglobs to pass variables around !
It's illegal ! It's punished by The Law (tm) ! It will not work with use strict !

If you want to pass a hash to a function you should use a reference to the hash, i.e :

my %hash = ( 'some' => 'things' ) ; callFunction( \%hash ) ;
In the function you can for example dereference the hash :
sub callFunction { my $refhash = shift ; my %hash = %$refhash ; ... }

Replies are listed 'Best First'.
Re^2: Scope of a Hash
by revdiablo (Prior) on Dec 15, 2005 at 20:02 UTC
    It will not work with use strict!

    It won't? Coulda fooled me.

    use strict; use warnings; sub foo { our $bar; $bar = "Hi"; return *bar; } my $foo = foo(); print $$foo, "\n"; __OUTPUT__ Hi

    Not that I disagree with the rest of your post, though. This type of thing is odd, but it's not disallowed by strict by any means.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2020-02-21 12:36 GMT
Find Nodes?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?

    Results (95 votes). Check out past polls.