experimental(3perl)
π experimental π
okay bestie, listen β the manual name is experimental and it lives in the Perl Programmers Reference Guide, and honestly? it's giving "let me hold your hand through the scary parts of perl." no cap.
β¨ VERSION β¨
we're on version 0.036 babes π
π SYNOPSIS π
use experimental 'lexical_subs', 'signatures';
my sub plus_one($value) { $value + 1 }
that's it. that's the whole vibe. π¦
πΈ DESCRIPTION πΈ
so basically this pragma is your one-stop lil interface for turning experimental features on or off. easy. convenient. iconic. π
every version of perl comes with some number of features that are present but considered "experimental." for most of Perl 5's whole life, that was literally just a label in the docs, like a lil sticky note. but starting in Perl v5.10.0, and then way more aggressively in v5.18.0, experimental features got put behind pragmata that you use to enable the feature and disable the associated warnings. gatekeeping but make it perl.
so the experimental pragma exists to smoosh all the required incantations into a single interface that stays stable across releases of perl. for every experimental feature, this should enable the feature and silence warnings for the enclosing lexical scope:
use experimental 'feature-name';
and to disable the feature and, if applicable, re-enable any warnings, you go:
no experimental 'feature-name';
the supported features, documented further below, are:
args_array_with_signaturesβ lets you use@_inside signatured subs. supported on perl 5.20.0 and above, but it's probably getting removed in the future. πarray_baseβ lets you use$[to change the starting index of@array. this was removed in perl 5.30.0.autoderefβ letspush,each,keys, and other built-ins work on references. added in perl 5.14.0 and removed in perl 5.24.0.bitwiseβ allows the new stringwise bit operators. added in perl 5.22.0.builtinβ lets you use the functions in thebuiltin::namespace. added in perl 5.36.0const_attrβ allows the:constattribute on subs. added in perl 5.22.0.classβ enables theclass,field, andmethodsyntax. added in perl 5.38.0.declared_refsβ enables aliasing via assignment to references. added in perl 5.26.0.deferβ lets you use defer blocks. added in perl 5.36.0extra_paired_delimitersβ lets you use more paired string delimiters than the traditional four,< >,( ),{ }, and[ ]. added in perl 5.36.for_listβ lets you iterate over multiple values at a time withfor. added in perl 5.36.0isaβ lets you use theisainfix operator. added in perl 5.32.0.keyword_allβ enables thealloperator. added in perl 5.42.0.keyword_anyβ enables theanyoperator. added in perl 5.42.0.lexical_topicβ lets you use lexical$_viamy $_. added in perl 5.10.0 and removed in perl 5.24.0.lexical_subsβ lets you use lexical subroutines. added in 5.18.0, and became non-experimental (and always enabled) in 5.26.0.postderefβ lets you use postfix dereferencing expressions. added in perl 5.20.0, and became non-experimental (and always enabled) in 5.24.0.postderef_qqβ lets you use postfix dereferencing expressions inside interpolating strings. added in perl 5.20.0, and became non-experimental (and always enabled) in 5.24.0.re_strictβ enables strict mode in regular expressions. added in perl 5.22.0.refaliasingβ allows aliasing via\$x = \$y. added in perl 5.22.0.regex_setsβ allows extended bracketed character classes in regexps. added in perl 5.18.0, and became non-experimental (and always enabled) in 5.36.0. this is documented at "Extended Bracketed Character Classes" in perlrecharclass.signaturesβ allows subroutine signatures (for named arguments). added in perl 5.20.0.smartmatchβ lets you use~~. added in perl 5.10.0, but heads up, there are significant incompatibilities between 5.10.0 and 5.10.1. the feature was deprecated in perl 5.38.0, and undeprecated in 5.42.0. it went through a whole arc, honestly.switchβ lets you use~~, given, and when. added in perl 5.10.0. the feature was deprecated in perl 5.38.0, and undeprecated in 5.42.0.tryβ lets you usetryandcatch. added in perl 5.34.0win32_perlioβ allows the use of the:win32IO layer. added on perl 5.22.0.
π§ Ordering matters π§
okay this one's important, don't skip it bestie. using this pragma to "enable an experimental feature" is literally just another way of saying this pragma disables the warnings that feature would throw at you. so the order you apply pragmas in? matters. a lot. specifically, you probably want to enable experimental features after you enable warnings:
use warnings;
use experimental 'smartmatch';
you also gotta be careful with modules that enable warnings for you. a super common example is Moose. watch this chaos: warnings for the 'smartmatch' feature get turned on by the warnings pragma, off by the experimental pragma, and then back on again by the Moose module. the fix is to switch the last two lines:
use warnings;
use experimental 'smartmatch';
use Moose;
π Disclaimer π
because of the nature of the features it enables, forward compatibility can not be guaranteed in any way. periodt. that's just the truth and we're saying it. π
π SEE ALSO π
perlexperiment contains more information about experimental features. go read it, it's the lore. π
π AUTHOR π
Leon Timmermans <fawaka@gmail.com>
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2013 by Leon Timmermans.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
and that's a wrap, my love π this was experimental for perl v5.44.0, dated 2026-10-17. go enable something weird and experimental, you absolute main character. slay. β¨π¦π
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms