Acme::Globule - Extensible package-local way to override glob()


Acme-Globule documentation  | view source Contained in the Acme-Globule distribution.

Index


NAME

Top

Acme::Globule - Extensible package-local way to override glob()

VERSION

Top

version 0.004

SYNOPSIS

Top

 # a simple plugin
 package Acme::Globule::Ping;

 sub globule {
   my($self, $pattern) = @_;
   # somebody did <ping> and so we want to return ('pong')
   return [ "pong" ] if $pattern eq 'ping';
   # they didn't ping, so pass
   return;
 }

 # a simple client
 package main;

 use Acme::Globule qw( Ping );

 # prints "pong'
 print <ping>;
 # prints the location of your home directory
 print <~>;

DESCRIPTION

Top

This package extends glob (and thus <>) to return custom results. It has a plugin mechanism and you define which plugins you wish to use on the import line. Now when you call glob(), these plugins will be tried left-to-right until one claims it, with a fall-through to the standard glob() function.

Each of your packages may use different plugins, and packages that do not import Acme::Globule will get standard glob() behaviour.

Creating a plugin

Top

To create a plugin, create a module Acme::Globule::* and provide a globule() method. The globule method should return an array reference containing the matches, or nothing if it wishes to decline and let the next plugin try it.

BUGS

Top

Any code that uses this module is perverse and therefore contains at least one bug.

This module globally hooks both File::Glob::csh_glob CORE::GLOBAL::glob, and so using this module anywhere in a program will cause all uses of glob() to suffer a slight performance hit even in other modules which do not use it.

glob() within an eval() will probably not do what you expect.

SEE ALSO

Top

Acme::Globule::*, the plugins.

AUTHOR

Top

Peter Corlett <abuse@cabal.org.uk>

COPYRIGHT AND LICENSE

Top


Acme-Globule documentation  | view source Contained in the Acme-Globule distribution.