Help for this page

Select Code to Download


  1. or download this
    $perl -we 'my(f($x))'
    Can't declare subroutine entry in "my" at -e line 1, at EOF
    Execution of -e aborted due to compilation errors.
    
  2. or download this
    $ perl -we 'my($x = 3)'
    Can't declare scalar assignment in "my" at -e line 1, at EOF
    Execution of -e aborted due to compilation errors.
    
  3. or download this
    $ perl -we 'my(local $x)'
    Can't localize lexical variable $x at -e line 1.
    $ perl -we 'perl -we 'local(my $x)'
    Can't localize lexical variable $x at -e line 1.
    $
    
  4. or download this
    $ perl -wE 'sub f {state (my $x); say ++$x} f; f;'
    1
    ...
    $ perl -wE 'sub f {state my $x; say ++$x} f; f;'
    No such class my at -e line 1, near "{state my"
    Execution of -e aborted due to compilation errors.
    
  5. or download this
    $ perl -wE 'sub f {our local $x; say ++$x} f; f;'
    No such class local at -e line 1, near "{our local"
    ...
    1
    1
    $