in reply to Is it ok to require a module in a sub or method?
I feel at ease only if my overall code architecture is built upon runtime loading, or if I require modules as a last resort, e.g.
sub bail_out { require Carp; Carp::confess(@_); }
I'd use a module like Cwd up front, btw. Consider AutoLoader. Likewise, you can define a namespace of a module without actually loading it, and declare stubs for methods/subroutines like
which will be defined only after the subroutine that requires the module has been called.package Cwd; sub cwd; package main; # or whatever module you are in ...
--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}
|
|---|