Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Scope of a Hash

by secret (Beadle)
on Dec 15, 2005 at 16:06 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-03-28 23:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found