
The most significant features introduced for recent versions of the Perl scripting language. Core security support is provided for 3 years, so typical users should run at least 5.34. Stable…
The most significant features introduced for recent versions of the Perl scripting language.
Core security support is provided for 3 years, so typical users should run at least 5.34. Stable distributions such as Debian 10 maintain 5.28+. Enterprise platforms retain versions up to 5.10.
use feature "module_true"no feature "bareword_filehandles"
sub ($var ||= default)//=) instead of omitted
/(*{ … })/(?{ … }) with regex optimisations enabled
classfield variables and method subroutines (feature, experimental)
${^LAST_SUCCESSFUL_PATTERN} s//…/
%{^HOOK}require__before and require__after when calling require
PERL_RAND_SEED srand random number seed
is_taintedbuiltin function to check variable tainting like Scalar::Util::tainted
export_lexicallybuiltin function to export named functions into the calling scope
use v5.36warnings; use feature qw'signatures isa'; no feature qw'indirect multidimensional switch'
use builtinweaken and blessed from Scalar::Util, ceil/floor from POSIX, and trim like String::Util (experimental)
is_bool(!0)builtin functions) for data interoperability
for my ($k, $v) (%hash)builtin::indexed for arrays) (feature, experimental)
defer {}try {} finally {}try construct regardless of failure (feature, experimental)
try {} catch/{,n}/\x{ … }\b{}, \g{}, \k{}, \N{}, \o{} as well as /{m,n}/ quantifiers
0o00o alternative to 0… and oct
re::optimization(qr//)no feature …bareword_filehandles and multidimensional array emulation
isa$min < $_ <= $max$min < $_ and $_ <= $max
/\p{Name=$var}/\N{} but with interpolation and subpatterns
open F, '+>>', undefno feature 'indirect'new Class instead of Class->new
/(?<=var+)<>variable length lookbehind assertions (experimental until 5.36)
m(\p{nv=/.*/})match unicode properties by regular expressions (experimental)
my $state if 0workaround for state (deprecated since v5.10!) is now prohibited
qr'\N'Delimiters must be graphemes; unescaped { illegal; \N in single quotes
Unicodev12.1
delete %hash{…}/(*…)/(*atomic:…) for (?>…) and (*nlb:…) for (?<!…) (experimental until 5.31.6)
/(*script_run:)/state @a -i -pe die${^SAFE_LOCALES}<<~EOT@{^CAPTURE}${^CAPTURE}[0] is $1
//xxuse Test2::V0Test::* and TAP::*
printf '%.*2$x'/\b{lb}//faster//i on caseless languages, 64-bit arithmetic, scope overhead
\$alias =<<>>readline ignoring open flags in arguments
/()/n() into (?:)
/\b{}/&.& | ^ ~ consistently numeric, dotted operators for strings (feature, experimental until 5.28)
use re 'strict'0x.beep+0printf '%a' to display
??m?PATTERN?
sub ($var)%hash{…}[]->@*$scalar->$* for $$scalar) (feature, experimental until 5.23.1)
use warnings 'once'; $a${^LAST_FH}$.)
/(?[ a + b ])/-, union +, intersection &, xor ^) (experimental until 5.36)
my substate, our); buggy before v5.22 (experimental until 5.26)
next $expressionno warnings 'experimental::…'__SUB__fc, "\F""\N{}"use charnames qw( :full :short )
s///r/(?{ m() })//(?{})/ and /(??{})/ (experimental until 5.20)
/daluuse re '/flags'/(?^)/FH->methodSTDOUT->flush)
\o{}use JSONdecode_json <>}
use HTTP::TinyLWP::UserAgent overhead
package versionpackage NAME VERSION shorthand for our $VERSION
...use 5.012strict if use VERSION >= v5.12
… whenwhen is now allowed to be used as a statement modifier
use overload 'qr'/\N//s (experimental until 5.18)
each $ref e.a.//~~sayprint @_, "\n" (feature)
givenwhen/default (feature, experimental)
/(?<name>)/%+
/(?1)//(?|)//.++/?+, *+, ++ to match greedily
s/keep\K//s/(keep)/$1/
/p${^MATCH} variables (avoiding $& penalty until COW in v5.20)
/\v/, /\h/\V \H to invert); also /\R/ for newlines
my $_statemy variables (scalars only until 5.28) (feature)
use autodieeval {open ...} or $@->matches("open") || die}
use IO::Compress::Zipzip IO::Uncompress::Gunzip->new("test.gz") => "recompressed.zip"}use Time::Piecelocaltime->year > 1900}
use File::FetchFile::Fetch->new(uri => "http://localhost/")->fetch(to => \$slurp)}no utf8utf8 pragma only for script encoding
use openbinmode $fh, ":bytes"}
open $fh, '-|', @cmdopen $fh, '>', \$varprintf '%1$s', @args1_2_3 == 123use bignumlength 1e100 == 101}
use ifno if $] >= 5.022, "warnings", "redundant"}
use sortuse Digest$hash = sha256_hex($data)}
use Encodeencode("utf8", decode("iso-8859-1", $octets))}
use File::Temp$fh = tempfile();}
use List::Util@cards = shuffle 0..51}
use Locale::MaketextLocale::* and L18N::*
use Memoizememoize "stat"}
use MIME::Base64use Test::Moreis $got, $expected}
use Time::HiRes$μs = [gettimeofday]; sleep .1; $elapsed = tv_interval $μs}use warningsuse utf8use charnames\N{} to insert named character
ourv1.2.3printf '%vd' to display)
0b0printf '%b', and oct
sub :lvalueopen my $fh, $mode, $exprpack 'q'sort $coderef ()($$) to pass elements as normal @_
CHECK {}/[[:…:]]//[[:alpha:]]/
Over the past 10-12 years, Perl has been getting some significant speed boosts, on the order of 30% overall. It is of course still a very slow language when compared to compiled languages, but I'll take it.
https://blogs.perl.org/users/dimitrios_kechagias/2022/11/per...
I still code in Perl a fair bit for work. One great improvement I have taken advantage of is subroutine arguments, rather than unpacking @_ at the head of each subroutine. It is much easier to tell what the sub expects, and if the caller passes the wrong number of args it is a compile time error.
The main draw for me is that regex is built into the syntax of the language, and not a library. If the task requires a lot of pattern matching and string manipulation and speed isn't that critical, I reach for Perl.
Perl aficionado here - I love Perl for its regex as well. Whenever I need to do serious regex work (log parsing, for example), I pull out Perl. Many of the engineers I’ve worked with also don’t realize that it makes an extremely good shell interaction tool (much more powerful and intuitive than Bash scripting, for example) and I have developed many a TUI with it. I eventually learned Python as well, but always saw Perl as superior in many ways, especially when raw performance isn’t a consideration.
perl has the distinction of being designed by a linguist and, for many coders (like me), it has a very smooth and easy feeling …
… others dislike the idea of $ sigils as “noun” markers and @ sigils to denote plurals but imo these features trick your brain into engaging these natural language concepts.
In contrast, I feel that Java is “heavy”, Python is “sciency” and so on.
The other distinctive aspect of perl is that it does not seek to constrain and block the coder. Strongly typed and opinionated languages (like Rust and Haskell) can be frustrating since they force you to code their way. That’s fine - it’s in the contract. perl is for when you just want a bag of tools to get the job done without becoming a wrestling match.
This flexibility also means that non standard code is easier to write in perl. The tool gets a bad reputation at the hands of poor coding practices. A higher level of trust and self-discipline is needed.
perl6 - now renamed to www.raku.org, continues the spirit with a cleaned up syntax and a lot more features in the core language
I really like Raku, but haven't yet tried to integrate it into anything I do. I was looking at fizzbuzz implementations on https://web.archive.org/web/20240116132452/https://rosettaco... (as you do), and liked the simplicity of a Raku solution:
for 1 .. 100 {
when $_ %% (3 & 5) { say 'FizzBuzz'; }
when $_ %% 3 { say 'Fizz'; }
when $_ %% 5 { say 'Buzz'; }
default { .say; }
}> perl has the distinction of being designed by a linguist
... who won the IOCC 2 times! https://www.ioccc.org/winners.html#W
in 1986 and 1987 ... yikes
https://www.linkedin.com/pulse/18th-december-day-perl-progra...
Obfuscation coding contests, Perl golf tournaments to create the shortest feasible code for a specified function, and Perl-language poetry collections have all grown up as a result of Perl's versatility.
Your takeaway may well be that perl is not the kind of thing that your boss would like. My takeaway is that perl (and raku) is versatile and engenders a sense of -Ofun.
> This flexibility also means that non standard code is easier to write in perl. The tool gets a bad reputation at the hands of poor coding practices. A higher level of trust and self-discipline is needed.
And this becomes a problem in teams.
I do somewhat miss perl, because perl and some libraries did some things better than later languages. You could express some ideas very concisely. Or, croak and carp only reporting functions crossing module or library boundaries in a stack trace (instead of some java teams complaining that the log aggregation refuses to collect 50kb+ sized stacktraces, not even exaggerating there).
Alternatives like python force you into a more maintainable style. Like, don't get me wrong, you can write unmaintainable code in any language, and python would be my language of choice to make a horrible non-understandable mess with the extensive meta programming capabilities.
But with perl, you kinda have to put in effort to stay on the simple path. If you leave that part, it quickly becomes very dark. And I know some of my co-workers.
For me, it's code review that makes me write in a maintainable style. It's the team that's responsible for a code base and objections are raised whenever anyone thinks that they'll struggle to understand this or that line. We also enforce consistency. Yes, you _can_ choose any character for quoting lists, but for the love of Pete, you _will_ follow how it's done in every other case (in that file, at least).
I'll miss you qw//, but I was out-voted. :(
qw// was always my favorite, too — distinctive, and quick to type.
qw/one two three/;
in raku is <one two three>Indeed, Linguistics is a sincerely underappreciated field.
It's telling that perl is/was absolutely functional at it's core -- a pidgin of bash and <proper programming>, if one might will.
yeah, raku takes the perl functional heritage and adds a bit
my $logger = -> $m { say $m; $m };
my $add-five = -> $x { $x + 5 };
my $add-five-and-log = $add-five o $logger;
say $add-five-and-log(25); # Prints 25, then prints 30
https://dev.to/rawleyfowler/functional-programming-with-raku...Surprisingly (but not really), I found myself in a position to harness my late-90s perl for cgi experience for the sciences after bioinformatics began to take off.
Python makes quite a few things easier if only because of how "teachable" it is between colleagues, but the really useful tools that bear more in common with the human relationship with data as text-at-scale were part and parcel to the POSIX-likes. The biggest challenges I faced were getting IT to let me use Linux at work and convincing peers to try it.
> perl6 - now renamed to www.raku.org, continues the spirit ...
With perl7 still being worked on, is it really a continuation or they're just branching off? I'm still not sure what's their relation to each other now. Why would one choose to use perl over raku or vice-versa?
My understanding is that there is Perl 5 (which is Perl) and a completely separate language known as Raku that was originally supposed to be Perl 6. This happened as Perl 6 took so long (similar to Duke Nukem Forever) that large portions of the Perl community decided it wasn't a realistic upgrade path and the languages had a hard fork.
Perl7 seems to be Perl5 with some changes to the defaults. They can't upgrade to Perl6 as that would be needlessly confusing. If foresight were perfect, Perl6 would have always been a different language name so Perl proper would continue without confusion. The problem was that they had no idea how hard it would be to make Perl6 and thus thought it would be ready in a few years (my understanding) and everyone would upgrade. Raku/Perl6 is SERIOUSLY COOL. I think it just needs a larger community and that's a chicken/egg problem.
Your understanding is mostly accurate.
Perl 6 was intended from the start to be the next major release of Perl (at various times, a replacement for a 5.10 or 5.12 or 5.14), and it was intended to have a backwards compatibility mode to run 5.8 (or 5.10 or 5.12) code in the same process, with full interoperability.
As time went by, that plan became less and less likely. Some people came up with the idea that Perl and P6 were "sister languages", both to have new major releases. I think this happened sometime around 2009 or so, maybe as early as 2007.
Also by 2011 or so, the P6 developers effectively scuttled the backwards compatibility plan and code written to that point, but I've argued that their plan to replace Parrot was a mistake enough here and elsewhere already. (Sometimes I wonder, now that MoarVM is older than Parrot was when Parrot was declared unsuitable, if they've achieved their promised speed and compatibility goals.)
Thanks Chromatic!
Well the raku community may be small (1300 ish on reddit) but it is very welcoming and there is lots to help out with (RakuAST anyone?). There are 2200 or so modules on www.raku.land (plus Inline::Perl5, Inline::Python, CFFI and so on) - I learn something every day by rubbing shoulders with some amazing experts!
Yep. I hope I didn't comes across as negative. It's a good community from what I've seen.
(conceptually) it's a fork - long overdue really since the whole stack has diverged
I like perl. Before, I had written a toy web server in perl (it was fun and I learned a lot), then I ported it to cosmopolitan to have it run everywhere!
This year I've written a fdisk replacement in perl, to make hybrid MBR+GPT for bootable media.
First, I wanted to check how they were made, but then I decided I wanted to programmatically write hybrid MBR in a way that's easier than gdisk and that offers more control that xorriso.
It's not complete yet, but the partition reading feature was already very helpful to understand the ins and out of the mfg59 layout that's so popular for optical media, and the final gpt tweaks should only take a few more days.
perl allowed me to write it very quickly and to make sure it will work reliably for the years to come.
Bummer you’d been downvoted for that. It sounds like quite the ambitious project that you’ve nearly got working. Cool!
But I’m also saying this while holding a sharp stick and slowly backing away. That is not the sort of thing I’d expect someone to write in Perl, and I’m experiencing an odd mix of “that’s amazing!” and “what on earth were you thinking, my friend?!”
> Bummer you’d been downvoted for that.
Some people have an instinctual dislike of things they've been told it's fashionable to hate. I resent that, because all programming languages are interesting in their own ways.
> It sounds like quite the ambitious project that you’ve nearly got working. Cool!
Oh it's already working, it just needs more polish :)
Check https://github.com/csdvrx/hdisk if you're interested
Actually, I'll try to submit it!
> That is not the sort of thing I’d expect someone to write in Perl, and I’m experiencing an odd mix of “that’s amazing!” and “what on earth were you thinking, my friend?!”
I wanted to do it quickly :)
For decoding weird formats that mix little and big ending, I think perl unpack/unpack is the fastest way.
Also, for computing crc32, I didn't have to bother much :)
I dig it, or at least the fact that you stuck it out. Well done. :)
Huh, wonder if people who aren’t familiar with the subject saw “GPT” and thought you were going off into AI gibberish land?
> Huh, wonder if people who aren’t familiar with the subject saw “GPT” and thought you were going off into AI gibberish land?
If they don't know GPT is a type of partition table, I think their stereotypical dislike of perl is the least of their problems!