GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
subroutines(3) User Contributed Perl Documentation subroutines(3)

subroutines - Use subroutines from another module

This document describes version 0.001 of subroutines (from Perl distribution subroutines), released on 2018-12-15.

 package Your::Module;
 use subroutines 'Another::Module';

To avoid require()-ing:

 use subroutines '-norequire', 'Another::Module';

This pragma declares routines in your module that are copied from another module.

 package Your::Module;
 use subroutines 'Another::Module';

is equivalent to this pseudo-code:

 package Your::Module;
 BEGIN {
     require Another::Module;
     for my $name (all_subroutines_in("Another::Module")) {
         *{"Your::Module::$name"} = \&{"Another::Module::$name"};
     }
 }

This is a form of code reuse when you cannot do:

 package Your::Module;
 use parent 'Another::Module';

because the original subroutines do not expect to be called as methods, and/or when your subroutines are not called as methods.

Another alternative is to declare "Your::Module" as an alias of "Another::Module", e.g. using alias::module.

 package Your::Module;
 use alias::module 'Another::Module';

but this copies everythng, not just subroutines.

Please visit the project's homepage at <https://metacpan.org/release/subroutines>.

Source repository is at <https://github.com/perlancar/perl-subroutines>.

Please report any bugs or feature requests on the bugtracker website <https://rt.cpan.org/Public/Dist/Display.html?Name=subroutines>

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

alias::module

parent, base

perlancar <perlancar@cpan.org>

This software is copyright (c) 2018 by perlancar@cpan.org.

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

2018-12-15 perl v5.40.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.