in reply to Fixed a year later...
in thread can't import using exporter
Personally I'd do this:
use strict; use warnings; BEGIN { package MyUtils; no thanks; use base "Exporter"; our @EXPORT = "shout"; sub shout { print @_, "!!!\n"; } 1; }; use MyUtils; shout "it works";
I don't have any problem with the BEGIN block. I'd always wrap inline packages in braces anyway, so it's just five extra letters before the opening brace.
If I want to factor out MyUtils into a separate file, it's just a matter of cutting everything inside the braces and pasting it into MyUtils.pm; then replace the now empty BEGIN {} block with use MyUtils;. Easy. (And if I was being a perfectionist, I could remove no thanks; from MyUtils.pm as it becomes superfluous.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Fixed a year later...
by perl-diddler (Chaplain) on Mar 27, 2013 at 23:24 UTC |