samirpatry has asked for the wisdom of the Perl Monks concerning the following question:


In my main program i read aconfig file and after that i will store those value in a variable.i have 3 module which need this varible.
open CONFIGFILE, "config.txt" or die $!; { local $/; $/ = undef; $DATA=<CONFIGFILE>; } my $Config = ACTI::Tiny->new(); $Config = ACTI::Tiny->read_string( $DATA ); our $s = $Config->{_}; *Header::s=*s; *Request::s=*s; *Response::s=*s;

in module i access this variable by using the use vars qw($s); But In case of Response module this "s" variable is not access.Where i lack something

Replies are listed 'Best First'.
Re: How to share a varible of main program to different module???
by shmem (Chancellor) on Sep 04, 2006 at 11:06 UTC
    in module i access this variable by using the use vars qw($s); But In case of Response module this "s" variable is not access.

    In which module? If it's module, say, Module, you can access the $s variable from within module Response as $Module::s. No need for typeglobs.

    Where i lack something

    Read this node and follow the links.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: How to share a varible of main program to different module???
by ForgotPasswordAgain (Vicar) on Sep 04, 2006 at 08:51 UTC
    To be honest, I can barely understand what you wrote, neither the comments nor the code. I think you have a module called Response and are trying to access the variable $s from that module, right? I think you need to add an our declaration in the Response module, but you should check the docs for 'our' for your situation. You might also want to check out the docs for 'do', if you're looking for quick-and-dirty configuration.