I got the concept...but how to pass the reference? I'm really not familiar
with the reference....too bad. :(



2010/4/29 Akhthar Parvez K <akht...@sysadminguide.com>

> Hi,
>
> On Thursday 29 Apr 2010, Remy Guo wrote:
> > I've got a problem in following script:
> > sub A  {
> >     our %a;
> >     $a{"fred"} = 1;
> > ...
> > }
> > sub B {
> >     if ($fred != $a{"fred"})  {
> >         print "fred failed.\n";
> >     }
> >     if ($bella != $a{"bella"}  {
> >         print "bella failed.\n";
> >     }
> > }
> >
> > The problem is, I made the hash %a in sub A but in sub B, the value in
> hash
> > %a is never read. The declaration "our" seems not effect.
> > Why?...
>
> Pass the hash reference as an argument while calling the function. Do
> remember that you can't pass the hash to a function, but just the hash
> reference. Also minimize (or even avoid) the use of declaring with "our",
> use argument passing instead.
>
> Regards,
> Akhthar Parvez K
> http://Tips.SysAdminGUIDE.COM <http://tips.sysadminguide.com/>
>
> UNIX is basically a simple operating system, but you have to be a genius to
> understand the simplicity - Dennie Richie
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>

Reply via email to