Coder Social home page Coder Social logo

package-localize's Introduction

NAME

Package::Localize - localize package variables in other packages

SYNOPSIS

Say you've got this pesky package someone wrote that decided to use globals:

package Foo;
our $var = 42;
sub inc { $var++ }

Whenever you call Foo::inc(), it'll always be increasing that $var, even if you call it from different places. Package::Localize to the rescue:

my $p1 = Package::Localize->new('Foo');
my $p2 = Package::Localize->new('Foo');

say $p1->inc; # prints 42
say $p1->inc; # prints 43

say $p2->inc; # prints 42

DESCRIPTION

This module allows you to use multple instances of packages that have package variables operated by the functions the module offers.

Currently there is no support for OO modules; functions only.

METHODS

new

my $p1 = Package::Localize->new('Foo');

Takes one mandatory argument which is the name of the package you want to localize.

Returns an object. Call functions from your original package as methods on this object to operate on localizes package variables only.

name

my $name = $p1->name;
no strict 'refs';
my $p1_var = ${"$name::var"};

Returns the name of the localized package.

BUGS AND CAVEATS

Currently there is no support for OO modules; functions only. Patches are definitely welcome though.

SEE ALSO

Package::Stash

REPOSITORY

BUGS

To report bugs or request features, please use https://github.com/zoffixznet/Package-Localize/issues

If you can't access GitHub, you can email your request to bug-Package-Localize at rt.cpan.org

AUTHOR

LICENSE

You can use and distribute this module under the same terms as Perl itself. See the LICENSE file included in this distribution for complete details.

package-localize's People

Contributors

zoffixznet avatar

Watchers

 avatar  avatar

package-localize's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.