in reply to problem with accessing PM file
This is a problem of scope.
When you declare my $s_month; you are scoping the variable to your main program.
You need to get the value from $schedule::s_month, and you do not need to re-declare this in your main program at all:
require schedule; print "\$smonth is $schedule::s_month ,\$sday is $schedule::s_day, \$s +year is $schedule::s_year\n";
Your other option is to write a proper perl module that exports $s_month into the main program namespace. Be warned though, if you do this you will still clobber that value if you declare my $s_month in your main program.
Check out perldoc perlmod for more information on writing a module.
Updated: I needed to brush up on my vs. main::. Thanks for pointing that out, Zed.
</ajdelore>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: problem with accessing PM file
by Zed_Lopez (Chaplain) on Jul 17, 2003 at 19:26 UTC |