|
Posted by Ben Morrow on April 2, 2008, 8:04 pm
Please log in for more thread options
Quoth abigail@abigail.be:
> _
> Gunnar Hjalmarsson (noreply@gunnar.cc) wrote on VCCCXXVIII September
> ^^ Abigail wrote:
> ^^ > David Harmon (source@netcom.com) wrote on VCCCXXVIII September MCMXCIII
> ^^ > [] On Mon, 31 Mar 2008 23:23:25 +0200 in comp.lang.perl.misc, Gunnar
> ^^ > [] >I do, I hope. :)
> ^^ > [] >
> ^^ > [] > foreach my $num ( 0 .. 0b11111 ) {
> ^^ > [] > local *_ = \ sprintf '%05b', $num;
> ^^ > []
> ^^ > [] What is *_ ? It looks like one of those magic perl variables, but
> ^^ > [] I don't find any documentation on it.
> ^^ >
> ^^ > It's a silly attempt to obfuscate the code.
> ^^
> ^^ I didn't do it for the sake of it; please see the sub-thread starting
> ^^ with
> ^^
>
http://groups.google.com/group/comp.lang.perl.misc/browse_frm/thread/1c6904d6a4774258/e56a5cb3831212df
> ^^ and the advice provided there by Ben and Brian.
>
>
> I read it. I still think it's obfuscated. Why use a package scoped glob
> if you can use a lexical variable (even $_)?
FWIW I entirely agree. For occasions where the convenience of $_ is
useful and 5.10 is not an option, a one-item for loop is a much cleaner
way of safely doing a local assignment than messing around with *_.
Ben
|