Help for this page

Select Code to Download


  1. or download this
    module Exporter;
    
  2. or download this
    use strict;
    use warnings;
    use warnings::register;    #assuming this continues to exist...
    
  3. or download this
    sub import($pkg : ARRAY $export=undef, ARRAY $ok=undef, HASH $tags=und
    +ef) {
    
  4. or download this
    ARRAY $export=undef
    
  5. or download this
    ARRAY $export //= undef
    
  6. or download this
        my $from_pkg=caller.package;
    
  7. or download this
        my $from_pag = caller.MY.package;
    
  8. or download this
        pkg_alias($from_pkg, "Exporter::From");
        &Exporter::From::import := &myimport;
    
  9. or download this
    sub pkg_alias($original, $new) {
        #Any sufficiently encapsulated hack...
    ...
    
        %{"${original}::"} := %{"${new}::"};    #XXX will this actually wo
    +rk?
    }
    
  10. or download this
    sub myimport($exp_from : *@symbols=() : *@options=()) {
    
  11. or download this
        my $exp_to=caller.package;    #is this how caller is used?
    
    ...
    
        #defaults
        @symbols //= @Exporter::From::EXPORT;
    
  12. or download this
        $foo ||= 'bar';
    
  13. or download this
        $foo //= $bar // $baz // 'nothing to see here, folks';
    
  14. or download this
        #expand tags to their values
        @symbols=map {
    ...
                @{%Exporter::From::EXPORT_TAGS}{$_}} ::
                $_
        } @symbols;
    
  15. or download this
        for(@symbols) {
            #handle version numbers
    ...
                $exp_from.require_version($_);
                next;
            }
    
  16. or download this
            #handle renamed exports
            my($to, $from)=$_.ref eq 'PAIR' ? ($_.left, $_.right) : ($_, $
    +_);
    
  17. or download this
            for($to, $from) {
                #make sure it has some sort of sigil
                $_='&' _ $_ unless m'^[$@%&]';
            }
    
  18. or download this
            warnings::warnif("$from exported from $exp_from conflicts with
    + existing $to at $(caller.file) line $(caller.line).\n")
                if defined %Exporter::To::{$to};
    
  19. or download this
            %Exporter::To::{$to}=%Exporter::From::{$from};
        }
    
  20. or download this
        for(@options) {
            my($sign, $name, $value)=/[+-]([[\w]&&[^\d]]\w+)(?:=(.*))?/s;
    ...
            }
        }
    }
    
  21. or download this
        if(defined $export) {
            @Exporter::From::EXPORT=@$export;
    ...
            %Exporter::From::EXPORT_TAGS=%$tags;
        }
    }
    
  22. or download this
        if(defined $export) {
            @Exporter::From::EXPORT = $export;
    ...
            %Exporter::From::EXPORT_TAGS = $tags;
        }
    }