secret has asked for the wisdom of the Perl Monks concerning the following question:
I have the following pm file :
Which is loaded by a script like this :use strict ; use warnings ; package FOO ; sub Principal::bof { my $fic = "toto" ; bof2() ; } sub bof2 { print $fic } 1;
This fails with Global symbol "$fic" requires explicit package name .use strict ; use warnings ; package Principal ; require ("ot.pm") ; Principal::bof() ;
I tried to do print $FOO:fic or print $Principal::fic in the bof2 sub but then it fails with Use of uninitialized value in print
I don't understand the namespaces relations in this . Is there a way i can access the value from bof2() without passing it as parameter ?
Thanks if you can help .
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: accessing $var problem due to package and subs
by ikegami (Patriarch) on Apr 05, 2006 at 16:42 UTC | |
|
Re: accessing $var problem due to package and subs
by eric256 (Parson) on Apr 05, 2006 at 16:54 UTC |