The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

autorequire - Generate module code on demand

SYNOPSIS

  use autorequire sub {
    my ($filename) = @_ ;
    if ($filename eq 'Useless.pm'){
      return "package Useless ;\n1 ;"
    }
    return undef ;
  } ;

DESCRIPTION

autorequire allows you to automatically generate code for modules that are missing from your installation. It does so by placing a hook at the end of the @INC array and forwarding requests to missing modules to the subroutine provided. autorequire guarantees that the hook registered will always be the last entry in @INC.

The subroutine must return the code for the module in the form of a filehandle, a scalar reference or a scalar. A return value of undef will pass control to the subroutine provided to the previous autorequire usage or will croak if autorequire was not previously used.

SEE ALSO

require, open.

AUTHOR

Patrick LeBoutillier, <patl@lcpan.org<gt>

COPYRIGHT AND LICENSE

Copyright (C) 2005 by Patrick LeBoutillier

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.