This probably falls under the category of Don't Do It!(tm), but what the hay.
I've seen some modules in the past that used LIST args in import to activate different defaults for the usage of that module.
For example, let's say I have a Foo module that can be set to ignore or Carp errors during the course of its lifetime. I can add a method to toggle this behaviour:
or I can use 'use' (Who's on first?) funkyness to accomplish the same:use Foo; Foo->err_raise(1); Foo->err_raise(0);
use Foo qw(:err_raise); use Foo qw(:err_ignore);
Besides the argument of whether it should or shouldn't be done, how is that accomplished?
Is it simply a matter of overloading import, or is there a cleaner way?
package Foo; use Exporter; @ISA = qw( Exporter ); ... sub import { my ($self, @args) = @_; ... check @args for :err_raise, :err_ignore change err handling defaults remove those fake tags from @args and call the real import ... $self->export_to_level(1, @cleanargs); };
Mod -1 points: Too Much Time On My Hands
In reply to Exporter, import, and tags w/ double meanings. by jk2addict
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |