If
you have a question on how to do something in Perl, or
you need a Perl solution to an actual real-life problem, or
you're unsure why something you've tried just isn't working...
then this section is the place to ask.
However, you might consider asking in the chatterbox first (if you're a
registered user). The response time tends to be quicker, and if it turns
out that the problem/solutions are too much for the cb to handle, the
kind monks will be sure to direct you here.
I am looking for an authoritative list of all of the currently experimental features in Perl (I thought it would be here in the experimental POD or here in the perlexperiment POD but the class feature does not appear in them so these cannot be considered authoritative). When I try to discuss Perl experimental features like the new native classes I get the anticipated warning:
#!/usr/bin/perl -w
use strict;
no CGI;
use v5.36;
use feature 'class';
# notice that I commented this out
#no warnings "experimental::class";
package Signals;
our $VERSION=1.0;
package Foo;
class Alpha 0.01 {
field $longname = "alpha!";
}
package main;
#...
Which is exactly what I want and it appears to be consistent with how other popular languages are handling experimental features. But what I need upon seeing this is as follows:
A single list for all experimental features currently in 'play.' I can see tickets flagged as 'experimental' on Github for Perl5. Is that the only/official way?
(Hopefully) access to a repository of modules being built against the experimental features (or perhaps some way to easily identify them in CPAN?)
I have noticed that it's also okay to just write blank, but when I try to substitute blank in place of the first undef, I get a syntax error. What would be the official or best practice to skip a variable in a list? I am asking this question, because what if they change Perl and in version 5.79 they introduce some new feature which means that "undef" as a placeholder will raise an error or warning in the code?
In versions 5.6 and later, Perl won't recompile the regular expression if the variable hasn't changed, so you probably don't need the /o option. It doesn't hurt, but it doesn't help either.
The bottom line is that using /o is almost never a good idea.
Then what about something like benchmark below (this is 5.42, and I _do_ see a small but noticeable performance bump with real code which does some heavy lifting when parsing. I don't think any variables have changed; just wanted to split pieces of a regex into separate variables for clarity):
use strict;
use warnings;
use feature 'say';
use Benchmark 'cmpthese';
my $pat = qr/\d+/;
my $s = '123abc' x 1e6;
cmpthese -1, {
foo => sub { 1 while $s =~ /\G $pat \D+ /cgx },
bar => sub { 1 while $s =~ /\G $pat \D+ /cgxo },
};
__END__
Rate foo bar
foo 1213522/s -- -88%
bar 10345112/s 752% --
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:
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.
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 @_;
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:
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...
"...This document was created in February, 2011, and the last major revision was in February, 2013....
I check metacpan...same document. I want to learn the latest techniques for OO in Perl. I remember reading that there were native classes added in 5.38. Is someone updating perlootut? Is is being superseded by another POD?
I feel like I have learned a lot in the past 10 years since I started learning Perl, but I still probably don't know more than half of what's possible using regex. I have often come across situations where I needed to identify which pattern occurs first in a string. So, I am not trying to capture a part of the pattern nor am I trying to identify if it occurs at all or where. I am just trying to figure our which of the possible patterns is FIRST in the string. For example:
Sample string: "AB ABDA DCACCB AAA BSAA CAAB ACS ABA DBA BA DASSABACA A"
I'm looking for either: BA[ABC]{2} OR CA[CD]{2} OR DA[SC]{2}
So, I would write: /BA[ABC]{2}|CA[CD]{2}|DA[SC]{2}/
Is there a way to get a return value of 1, 2, or 3 depending on which pattern was matched first? How would I do that?