rolfy has asked for the wisdom of the Perl Monks concerning the following question:
t1.pl:#!/usr/bin/env perl package test; sub Init { $[ = 1; } sub test { print "(\$[= $[) array has " . scalar @_ . " elements, last index += $#_\n"; } 1;
As it turned out, even without calling test::Init, the mere fact that that is in that function has somehow globally turned on that option...#!/usr/bin/env perl use test; test::test(1,2,3,4); # test::Init(); test::test(1,2,3,4);
and in perl 5.10# perl 5.8.8 output ./t1.pl ($[= 1) array has 4 elements, last index = 4 ($[= 1) array has 4 elements, last index = 4
regardless of whether i call Init or not. I'm not sure why this happens, and it looks like it was a bug in perl 5.8.8 that wasn't listed as resolved in perl 5.10 but is...# perl 5.10 $ ./t1.pl ($[= 0) array has 4 elements, last index = 3 ($[= 0) array has 4 elements, last index = 3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: fun with $[
by ikegami (Patriarch) on Aug 06, 2008 at 03:44 UTC | |
|
Re: fun with $[
by parv (Parson) on Aug 06, 2008 at 02:21 UTC | |
|
Re: fun with $[
by syphilis (Archbishop) on Aug 06, 2008 at 02:39 UTC | |
|
Re: fun with $[
by Perlbotics (Archbishop) on Aug 06, 2008 at 14:23 UTC | |
|
Re: fun with $[
by JadeNB (Chaplain) on Aug 20, 2008 at 21:05 UTC |