develooper Front page | perl.perl5.porters | Postings from October 1999

Extending Exporter's import method

Thread Next
Moore, Paul
October 28, 1999 03:57
Extending Exporter's import method
Message ID:
I'm putting the finishing touches on my changes to File::Glob. What I'd like
to do is to extend the import() method supplied by Exporter, to take two
"special" tags, :case and :nocase, which set the case sensitivity of the
exported csh_glob() function. The idea is that use File::Glob qw(csh_glob
:nocase) will make csh_glob() case insensitive, and use File::Glob
qw(csh_glob :case) will make it case sensitive. The default will be platform

Ideally, I'd like these to be tags (starting with a ':') to stop people
thinking they might be exported functions... (The fact that the existing
'globally' export entry does not start with a colon worries me, that it may
not be easy to do this.)

My first thought was to define my own import sub, along the lines of

    sub import {
        my $self = shift;
        my @args;
        for (@_) {
            if (/^:(no)?case$/) {
                # Do the magic
            push @args, $_;

However, this didn't work. Can anybody tell me why, and how to do what I was
trying to do? (BTW, if this works, I'd be tempted to suggest doing
'globally' the same way - it would save nasty surprises for people doing
"use File::Glob ':ALL'".

On a slightly related note, is there any reason why GLOB_CSH is omitted from
the list of exported flag values?

On another related note, could I suggest a further tag, :flags, which
exported the flags, but NOT the glob() routine?


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About