in reply to Is it ok to require a module in a sub or method?

That's fine. Bear in mind, though, that requiring a module at runtime may change the overall behaviour of your code. After requiring a module, the namespace of that module is globally visible, and requiring it may change the inheritance chain (?). If the runtime-required modules define symbols that are deferred to be handled via AUTOLOAD by modules which have the current (requiring module) in its @ISA, strange and hard to debug things might happen.

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

package Cwd; sub cwd; package main; # or whatever module you are in ...
which will be defined only after the subroutine that requires the module has been called.
This is a dark corner I have to lighten up for myself, yet.

--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}