D
D
Daniel Literate2016-10-05 13:17:30
Perl
Daniel Literate, 2016-10-05 13:17:30

Why doesn't the state function work in Perl without a version?

As stated in the documentation, the state function appeared in version 5.10 and it is necessary to add a directive or higher to the code. At the moment, version 5.24.0 is on the device, without specifying this directive, the interpreter swears. I can write and then the code will work. Why can't I use state without specifying a version? use v5.10;
use v5.24.0;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
targumon, 2016-10-05
@Fuckoff95

This is for backward compatibility with older versions.
Instead of specifying a version, you can use the feature pragma:use feature qw{ state };

R
Rsa97, 2016-10-05
@Rsa97

RTFM

state is available only if the state feature is enabled or if it is prefixed with CORE::. The state feature is enabled automatically with a use v5.10(or higher) declaration in the current scope.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question