base::Glob - Establish IS-A relationships based on globbing patterns


base-Glob documentation Contained in the base-Glob distribution.

Index


Code Index:

NAME

Top

base::Glob - Establish IS-A relationships based on globbing patterns

SYNOPSIS

Top

  package Class::Bar; sub method {2};
  package Nomatch::Foo; sub method {3};
  package main;
  use base::Glob qw(Class::*);
  print main->method(); # prints 2

DESCRIPTION

Top

This module allows you to extend base to form IS-A relationships with the use of globs on packages in the symbol table - in the style of Java's 'import java.class.*;'.

DEPENDENCIES

Top

Text::Glob Devel::Symdump Sub::Uplevel

BUGS

Top

Probably.

TODO

Top

Go all the way to Java-style by spidering to find modules to require and add to @ISA.

AUTHOR

Top

Chris Ball, <chris@cpan.org>.

THANKS

Top

Michael Schwern for Sub::Uplevel, Andreas Koenig for Devel::Symdump, Richard Clamp for both Text::Glob and being scary enough to work out that Sub::Uplevel would make this work.


base-Glob documentation Contained in the base-Glob distribution.

package base::Glob;
use vars '$VERSION'; 
$VERSION = '0.01';

use strict;
use Text::Glob qw( match_glob );
use Devel::Symdump;
use Sub::Uplevel;
require base;

sub import {
    shift;
    my @packages = Devel::Symdump->rnew->packages;
    
    uplevel 1, \&base::import, 
        ( 'base', map { match_glob $_, @packages } @_ );
}

1;

__END__