Perl: What exact features does 'use 5.014' enable?

后端 未结 3 1969
甜味超标
甜味超标 2021-01-01 14:06

What exactly does \'use 5.014\' enable?

Please, someone copy&paste here, because i was not able find it in any perldoc. (maybe i\'m blind). In the \'perldoc feat

3条回答
  •  时光说笑
    2021-01-01 14:33

    The use x.x.x pragma does turn on some features, and it's easy enough to test this:

    #!/usr/bin/env perl
    use warnings;
    use 5.14.0;
    
    say "hello world!"
    

    Runs great; outputs "hello world!".

    #!/usr/bin/env perl
    use warnings;
    # use 5.14.0;
    
    say "hello world!"
    

    Flaming death; outputs this error message:

    Unquoted string "say" may clash with future reserved word at foo line 5.
    String found where operator expected at foo line 5, near "say "hello world!""
        (Do you need to predeclare say?)
    syntax error at foo line 5, near "say "hello world!""
    Execution of foo aborted due to compilation errors.
    

    I'm not, however, 100% sure which features are turned on as of 5.14.0. I believe that you get say, state, switch, unicode_strings and strict.

提交回复
热议问题