On Tue, Sep 28, 2010 at 07:07:38PM -0400, Greg London wrote: > Ive used $arr[-2] to get the second to last element of an array. > But anyone using $[ to change the first index of an array to be > negative should be beaten severely.
I had initially thought this too; though I imagined something worse than a beating. However, upon further thought, I think it can be occasionally useful to change the first index of an array. Unfortunately, the most useful example I can come up with is from another language. In Lua, the equivalent of $ARGV[0] contains the script name while lower indices reference earlier parts of the invocation. So lua -i script.lua 24 creates the equivalent of $ARGV[-2] = 'lua' $ARGV[-1] = '-i' $ARGV[0] = 'script.lua' $ARGV[1] = '24' The point here being that the "useful" data starts at $ARGV[0] while, perhaps less useful, data exist at earlier indices. Of course this is a contrived example and Lua arrays are different enough from Perl arrays to make this simple. I think '$[' would more useful if it could be scoped to individual arrays. Though it does seem to be of dubious utility to begin with. -Gyepi _______________________________________________ Boston-pm mailing list [email protected] http://mail.pm.org/mailman/listinfo/boston-pm

