Help for this page

Select Code to Download


  1. or download this
    $[++; # No go.
    $[+=1; # Not happening
    $[ = $[; # Works.
    ...
    print \$[; # Ok, works.
    $[ = \$[; # which also works
    print $[; # Whoo fun!
    
  2. or download this
    $[=-1;
    @_=qw/foo bar baz/;
    print $_[-1]; # foo
    print $_[-2]; # bar
    print $_[-3]; # foo
    
  3. or download this
    #WRONG:
    for(my $i=0; $i<$#foo; $i++){}
    #RIGHT:
    for(my $i=$[; $i<$#foo; $i++){}
    
  4. or download this
    #WRONG:
    foreach(0..$#foo){}
    #RIGHT:
    foreach($[..$#foo){}