Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Well, when I use the package and call those functions, they won't work with stuff like the following (Perl nags that I must use a hash and not a hash reference):sub foo(\%) { my $h = shift; # do something with it... $h->{"FOO"} = "Hello, world!"; }
But calling it with foo(%stash) works. Why is that? The prototype says to expect a hash reference after all. I tried eyeballing through the Perl Cookbook, Learning Perl, Programming Perl and even Advanced Perl Programming but found no help. I have use strict pragma turned on. Am I missing something subtle here? I wish my function prototypes were consistent... Anyone?my %stash; foo(\%stash);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Hash reference question
by davorg (Chancellor) on Jul 13, 2000 at 16:22 UTC | |
by splinky (Hermit) on Jul 13, 2000 at 20:57 UTC | |
by Anonymous Monk on Jul 13, 2000 at 17:47 UTC | |
|
Re: Hash reference question
by Abigail (Deacon) on Jul 13, 2000 at 22:27 UTC | |
by Anonymous Monk on Jul 14, 2000 at 13:24 UTC | |
|
Re: Hash reference question
by c-era (Curate) on Jul 13, 2000 at 15:13 UTC | |
|
I forgot something
by Anonymous Monk on Jul 13, 2000 at 15:12 UTC |