bare.pm - scalars without sigils
use bare qw(foo bar); foo=3; bar=4; print foo+bar; #7 foo=bar=3; print foo=5,foo+bar #58 # Note that foo and $foo are aliased, eg: die unless foo==$foo; die unless bar==$bar; print "foo: $foo, bar: $bar"; #foo: 3, bar: 3
Everyone knows that Perl looks like line noise. Not anymore! bare.pm lets you access scalar variables without a leading sigil.
Note carefully that these are not lexical variables. You can only have one variable foo, which is aliased to the package variable $foo. You can, however, localize such a variable like so:
foo
use bare 'foo'; foo=3; { local $foo = 7; die unless foo==7; } die unless foo==3;
There are various other cases where you will have to use a sigil, eg:
To interpolate a bare in a string: use bare 'x'; print "x=$x" For use on a loop variable, eg: use bare 'x'; for $x (0..20) { ... }
bares are implemented as subs, so sigil-less access is quite a bit slower than "native" scalars that use sigils. For code where performance is important, you'll have to use sigils.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Brian Szymanski
To install bare, copy and paste the appropriate command in to your terminal.
cpanm
cpanm bare
CPAN shell
perl -MCPAN -e shell install bare
For more information on module installation, please visit the detailed CPAN module installation guide.