in reply to fun with $[
Cannot test it without 5.10 here, sorry.!/usr/bin/perl use strict; package LocalBlock; { # localisation scope local $[ = 1; sub test { # now a closure print "(\$[= $[) array has " . scalar @_ . " elements, last index = $#_ (", join(", ", @_) , ")\n"; } } # end of scope 1; package main; print "Pre: \$\[ = $[ \n"; LocalBlock::test(1,2,3,4); print "Post: \$\[ = $[ \n\n"; $[ = 5; print "Pre: \$\[ = $[ \n"; LocalBlock::test(5,6,7,8); print "Post: \$\[ = $[ \n\n"; __END__ Pre: $[ = 0 ($[= 1) array has 4 elements, last index = 4 (1, 2, 3, 4) Post: $[ = 0 Pre: $[ = 5 ($[= 1) array has 4 elements, last index = 4 (5, 6, 7, 8) Post: $[ = 5
|
|---|