Help for this page

Select Code to Download


  1. or download this
    my $x = "def";
    say ref( \substr( $x, 0, 0 ) );  # LVALUE
    substr( $x, 0, 0 ) = "abc";
    say $x;                          # abcdef
    
  2. or download this
    my $x = "def";
    my $r = \substr( $x, 0, 0 );
    say ref( $r );                   # LVALUE
    $$r = "abc";
    say $x;                          # abcdef
    
  3. or download this
    $ perl -Mv5.014 -e'
       sub f { my $REF = \$_[0]; say ref( $REF ); }
       f substr( "", 0, 0 );
    '
    LVALUE
    
  4. or download this
    $ perl -Mv5.014 -e'
       sub f { say ref( \$_[0] ); }
       f substr( "", 0, 0 );
    '
    LVALUE