This hack shows how to define ONE module (here "Classy" YMMV) which creates as many types and package variables in the callers package as you want to.
use strict; use warnings; use lib '.'; use Classy ; my Str $a ="Goliath"; # no compilation error $var //= 'Philistine'; # no compilation error print $var;
module
package Classy; use strict; use warnings; sub import { my $pkg = (caller())[0]; eval 'require Str'; no strict 'refs'; *{"${pkg}::var"} = \(my $var); } 1;
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
In reply to Re: perl 5 suggestions? (hack it yourself)
by LanX
in thread perl 5 suggestions?
by iaw4
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |