Front page | perl.perl5.porters |
Postings from September 2009
$[ replacement
Thread Next
From:
Father Chrysostomos
Date:
September 20, 2009 14:49
Subject:
$[ replacement
Message ID:
220067F0-4A98-4115-90EB-4FBB3ADC6C63@cpan.org
$[ has now been deprecated in blead (by change
#55b6781562aff32ef6499c4f263ab251254ca5cb). This is a useful feature,
yet its use has long been discouraged. I suspect that this is because $
[ as a pragma was such a hack. So I would like to suggest that it be
made a real pragma, seeing it has been deprecated with no replacement.
Attached is a proof-of-concept, called arybase.pm, which is strikingly
simple and short, but which relies on undocumented internals. Hence it
is probably unwise to make it a standalone CPAN distribution. Could
this be included in core (once I’ve added tests, docs, etc.)?
For those who cannot see where this feature is useful, I use this in
10- to 20-line blocks in which a dozen instances of $_ and $_+1 would
occur when $[ is not used. In such cases $[ (or arybase) just makes
the code *much* easier to read. Yes, there are alternatives (like
‘local @array = (undef, @array)’), but none of them is as elegant as
‘use arybase "1"’.
Father Chrysostomos
P.S.: Please CC any replies, since I have not subscribed to p5p.
Thread Next
-
$[ replacement
by Father Chrysostomos