Underscore in scalar name not in main package
5 direct replies — Read more / Contribute
|
by InfiniteSilence
on May 08, 2026 at 15:49
|
So I am looking around in perlvar and I learn that if you preface a scalar variable name with an underscore it will by default be in the main package...wow, I think. I want to try that:
perl -e 'package Nether; our $val = 2000; my $_nonesuch = 3000; packa
+ge main; print __PACKAGE__ . qq~\t~ . $main::_nonesuch;'
Makes: main
What? ...what happened by my value? So I take away the package portion:
perl -e 'package Nether; our $val = 2000; my $_nonesuch = 3000; packa
+ge main; print __PACKAGE__ . qq~\t~ . $_nonesuch;'
main 3000
As an aside I should mention why I keep posting these cryptic things about basic Perl functionality. I am researching why people run into problems with Perl and give up. The target audience (for now) includes project management and product owners who have enough familiarity with the language to recommend its use but want to simultaneously reduce the backlash that might come from doing so.
Celebrate Intellectual Diversity
|
perllocal EXE_FILES and %Config
1 direct reply — Read more / Contribute
|
by Anonymous Monk
on May 08, 2026 at 07:56
|
I noticed some inconsistent entries in perllocal
for modules that have EXE_FILES:
Acme::MetaSyntactic (script/ is typical)
EXE_FILES: script/meta script/metafy
Pod::Parser
EXE_FILES: scripts/podselect
CGI-Kwiki
EXE_FILES: inc/SCRIPTS/kwiki-install
GD
EXE_FILES: bdf_scripts/bdf2gdfont.pl
App::FatPacker (bin/ is typical too)
EXE_FILES: bin/fatpack
Despite all that, everything listed as EXE_FILES ends up
in the same directory, specified (on my system) by 12 %Config variables
with the same exact value as $Config{bin}:
/Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
My question is this: do these 12 Config variables have the same
value on all Perl installations? I guess there are actually 14
of these same vars, but the vendor values are blank on my system.
Here's a little script to check. I'd like to know if these
can be different values so I know which one(s) to use.
Thanks in advance.
#!/usr/bin/perl -l
# Check if all the bin and script dirs in %Config are the same.
use strict;
use warnings;
use Config;
@_ = qw/bin
binexp
initialinstalllocation
installbin
installscript
installsitebin
installsitescript
scriptdir
scriptdirexp
sitebin
sitebinexp
sitescript
sitescriptexp
vendorbin
vendorbinexp/;
printf "%-24s %-100s\n", $_, $Config{$_} for @_;
Output on my system:
bin /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
binexp /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
initialinstalllocation /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
installbin /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
installscript /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
installsitebin /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
installsitescript /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
scriptdir /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
scriptdirexp /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
sitebin /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
sitebinexp /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
sitescript /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
sitescriptexp /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
vendorbin
vendorbinexp
|
How do you determine what version of Perl your program requires?
3 direct replies — Read more / Contribute
|
by Anonymous Monk
on May 07, 2026 at 18:55
|
perlver seems to do a good job of figuring out the syntax (except that --blame often fails to find the reason), but what about modules? Perl::MinimumVersion says "Future plans are to also add support for tracing module dependencies"
but that hasn't happened yet. One might think corelist would help with core modules but it can be misleading. Let's say we use List::Util:
% corelist List::Util
List::Util was first released with perl v5.7.3
But 5.7.3 is not the version needed if uniq or uniqnum are used:
https://metacpan.org/dist/Scalar-List-Utils/changes:
1.44 -- 2016/03/17 23:08:46
CHANGES
* Added List::Util::uniq() and uniqnum()
% corelist -a List::Util | grep 1.44
NOPE
% corelist -r | grep 2016
v5.22.2 2016-04-29
...
5.22.2 is required to support uniq (or maybe an updated List::Util if that's possible). How do you determine what version of Perl your program requires? A robot told me this is a real gap in the Perl ecosystem...
|
perldoc -lf anomaly
2 direct replies — Read more / Contribute
|
by Anonymous Monk
on May 07, 2026 at 15:44
|
Why does "perldoc -lf splice" return perlfunc and perlop when the word "splice" does not exist in perlop?
% perldoc -lf splice
/Users/u/perl5/perlbrew/perls/perl-5.42.0/lib/5.42.0/pods/perlfunc.pod
/Users/u/perl5/perlbrew/perls/perl-5.42.0/lib/5.42.0/pods/perlop.pod
% grep 'splice' /Users/u/perl5/perlbrew/perls/perl-5.42.0/lib/5.42.0/pods/perlfunc.pod
L<C<splice>|/splice ARRAY,OFFSET,LENGTH,LIST> has three scalar arguments
... (19 lines deleted for brevity)
% grep 'splice' /Users/u/perl5/perlbrew/perls/perl-5.42.0/lib/5.42.0/pods/perlop.pod
% <- NOTHING!
|