NAME

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

SYNOPSIS

# 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

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

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

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

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

Acme::Globule::*, the plugins.

AUTHOR

All code and documentation by Peter Corlett <abuse@cabal.org.uk>.

COPYRIGHT

Copyright (C) 2008 Peter Corlett <abuse@cabal.org.uk>. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SUPPORT / WARRANTY

This is free software. IT COMES WITHOUT WARRANTY OF ANY KIND.