Fwd: using a subroutine ref w/ strict refs

Wilson, Doug Doug_Wilson at intuit.com
Wed Oct 17 12:48:57 CDT 2001


~sdpm~


> There's one caveat to this style. It'll break if this code is ever 
> evaluated in a package other than main, so it should be avoided in a 
> mod_perl or other Web server context.

Yeah its not very good OO-style, but it is similar to the
File::Spec module (and there are complaints about that
module's style, which is why another module was written in
a functional style). You put all the functions in a package,
say 'MyPackage', then all calls are made like:
MyPackage->function_name(@args)

or in this case:
MyPackage->$command

And in an Apache::Registry script mod_perl environment, I like to put
functions off in their own module anyway, so you don't end up with
those 'function redefined' warnings when just the main script changes, or
those 'variable won't stay shared' warnings when subroutines use
closures or globals etc.

-Doug
~sdpm~

The posting address is: san-diego-pm-list at hfb.pm.org

List requests should be sent to: majordomo at hfb.pm.org

If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at happyfunball.pm.org> with the following
command in the body of your email message:

    unsubscribe san-diego-pm-list

If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
This is the general rule for most mailing lists when you need
to contact a human.




More information about the San-Diego-pm mailing list