On Fri, Nov 28, 2008 at 12:17:29PM +0900, Raymond Wan wrote: > Thank you Alan, Hans, and Ben for your replies! The good news is that > Hans' suggestion worked; the "bad" news is that I don't understand one > point still and am wondering if someone could explain it to me even > though it seems like "basic Perl"... > > What I have now is: > > { > package HTML::Mason::Commands; > use MyUtils; > } > > May I ask what is the purpose of these parentheses? I know they limit > scope, so its purpose is to incorporate "MyUtils" into the package > HTML::Mason::Commands only and not affect anything else in my handler > file (i.e., the file that my handler is in)?
Yes. I used the {} because I didn't know what else was in your handler file, and that was the easiest way to limit the scope of my suggestion. Instead of 'incorporate', it would be more common to say that the purpose is to import MyUtils into HTML::Mason::Commands. See perldoc Exporter, which then points to perlfunc and perlmod. Nothing here is magic; it's just copying functions into a new package for You. you could get the same effect by hand if you did something like this: # assuming MyUtils exports myfunction and otherfunction, eg. with # Exporter, Sub::Exporter, manually, whatever *HTML::Mason::Commands::myfunction = \&MyUtils::myfunction; *HTML::Mason::Commands::otherfunction = \&MyUtils::otherfunction; Of course, that's tedious and error-prone, which is why you write 'use MyUtils' instead, but it helps answer your other question: > I also have other "use" > statements in the file: > > use Apache2::Status ( ); > use HTML::Mason::ApacheHandler; > use Apache2::Const -compile => ':common'; > use Apache2::Upload; > use Benchmark; > > how do I decide whether they should also be included in or does it not > matter? If they export functions that you want to be usable directly from your components (that is, as 'foo()' instead of 'Some::Package::foo()'), they need to be 'use'd while inside the HTML::Mason::Commands package. Otherwise they don't. hdp. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users