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 β€” lets push, 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 the builtin:: namespace. added in perl 5.36.0
  • const_attr β€” allows the :const attribute on subs. added in perl 5.22.0.
  • class β€” enables the class, field, and method syntax. 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.0
  • extra_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 with for. added in perl 5.36.0
  • isa β€” lets you use the isa infix operator. added in perl 5.32.0.
  • keyword_all β€” enables the all operator. added in perl 5.42.0.
  • keyword_any β€” enables the any operator. added in perl 5.42.0.
  • lexical_topic β€” lets you use lexical $_ via my $_. 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 use try and catch. added in perl 5.34.0
  • win32_perlio β€” allows the use of the :win32 IO 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>


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