@kyanny's blog

My thoughts, my life. Views/opinions are my own.

今日のPerlMonks


I wrote a module for use in-house that uses methods from various CPAN modules. I don't want to rely on other developers who use my module to include the "use" statements for the required CPAN modules in their programs, so I put a "use" statement for each CPAN module inside my methods as needed.

Is this bad practice? Will it hurt anything? (I assume "no" to both questions, but I could be wrong.)

Also, will any problems (or benefits) arise from developers adding "use" statements for the same CPAN modules in their own programs?

回答のほうを読んで、自作モジュールのサブルーチン内で必要に応じて use Module; を書くやり方の是非の話だってことはわかった。どうせ use がコンパイル時に実行されるのだからモジュールの先頭にまとめて書いておいてよくね?オンデマンドに呼び出したいなら require 使えばいいよね、という(オンデマンドって言いたかっただけ)それはわかったんだけど、もともとの質問の文面がイマイチわからん・・・そういうことを聞いてるのか?そうなんだろうなあ。ううむ。