Code Comments
Programming Forum and web based access to our favorite programming groups._
Frank Seitz (devnull4711@web.de) wrote on VCCCXXVIII September MCMXCIII
in <URL:news:65hdm3F2fp9u0U1@mid.individual.net>:
:: Abigail wrote:
:: >
:: > It's a silly attempt to obfuscate the code.
:: >
:: > It's much better written as:
:: >
:: > foreach (0 .. 0b11111) {
:: > my $_ = sprintf '%05b' => $_;
:: > tr _01_NY_;
:: > say "$::_:$_";
:: > }
::
:: Nice.
::
:: > No silly typeglobs needed.
::
:: You forgot
::
:: use 5.10.0;
And I "forgot" #!/usr/bin/perl, I "forgot" "vi whatever",
I "forgot" "perl whatever", etc, etc.
I just focus on the important bit, and don't like to clutter the messages
with details.
Abigail
--
perl -Mstrict -we '$_ = "goto C.print chop;\n=rekcaH lreP rehtona tsuJ";C1:e
val'
Post Follow-up to this messageAbigail wrote: > Frank Seitz (devnull4711@web.de) wrote on VCCCXXVIII September MCMXCIII > :: You forgot > :: > :: use 5.10.0; > > And I "forgot" #!/usr/bin/perl, I "forgot" "vi whatever", > I "forgot" "perl whatever", etc, etc. > > I just focus on the important bit, and don't like to clutter the messages > with details. Okay, but without this statement your program doesn't run - even under Perl 5.10. So it *is* important. Frank -- Dipl.-Inform. Frank Seitz; http://www.fseitz.de/ Anwendungen fόr Ihr Internet und Intranet Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel
Post Follow-up to this messageAbigail wrote:
> David Harmon (source@netcom.com) wrote on VCCCXXVIII September MCMXCIII
> in <URL:news:fb6dnc-9EJLmcm_anZ2dnUVZ_rSrnZ2d@earthlink.com>:
> [] On Mon, 31 Mar 2008 23:23:25 +0200 in comp.lang.perl.misc, Gunnar
> [] Hjalmarsson <noreply@gunnar.cc> wrote,
> [] >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...56a5cb3831212df
and the advice provided there by Ben and Brian.
See also Ben's reply in this thread.
http://groups.google.com/group/comp...c4e0ee726c4cded
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Post Follow-up to this messageDavid Harmon wrote: > On Mon, 31 Mar 2008 23:23:25 +0200 in comp.lang.perl.misc, Gunnar > Hjalmarsson <noreply@gunnar.cc> wrote, > > What is *_ ? It looks like one of those magic perl variables, but > I don't find any documentation on it. Others have told you that it's a typeglob and pointed you to relevant docs. As regards applicable docs on _the reason_ why I didn't just say local $_ = sprintf ... please see the "Localization of globs" section in "perldoc perlsub". -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl
Post Follow-up to this message_
Gunnar Hjalmarsson (noreply@gunnar.cc) wrote on VCCCXXVIII September
MCMXCIII in <URL:news:65i7ejF2f3g2iU1@mid.individual.net>:
^^ Abigail wrote:
^^ > David Harmon (source@netcom.com) wrote on VCCCXXVIII September MCMXCIII
^^ > in <URL:news:fb6dnc-9EJLmcm_anZ2dnUVZ_rSrnZ2d@earthlink.com>:
^^ > [] On Mon, 31 Mar 2008 23:23:25 +0200 in comp.lang.perl.misc, Gunnar
^^ > [] Hjalmarsson <noreply@gunnar.cc> wrote,
^^ > [] >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...56a5cb3831212df
^^ 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 $_)?
Abigail
--
A perl rose: perl -e '@}>-`-,-`-%-'
Post Follow-up to this messageAbigail wrote:
> _
> Gunnar Hjalmarsson (noreply@gunnar.cc) wrote on VCCCXXVIII September
> MCMXCIII in <URL:news:65i7ejF2f3g2iU1@mid.individual.net>:
> ^^ Abigail wrote:
> ^^ > David Harmon (source@netcom.com) wrote on VCCCXXVIII September MCMXCI
II
> ^^ > in <URL:news:fb6dnc-9EJLmcm_anZ2dnUVZ_rSrnZ2d@earthlink.com>:
> ^^ > [] On Mon, 31 Mar 2008 23:23:25 +0200 in comp.lang.perl.misc, Gunnar
> ^^ > [] Hjalmarsson <noreply@gunnar.cc> wrote,
> ^^ > [] >I do, I hope. :)
> ^^ > [] >
> ^^ > [] > foreach my $num ( 0 .. 0b11111 ) {
> ^^ > [] > local *_ = \ sprintf '%05b', $num;
> ^^ > []
> ^^ > [] What is *_ ? It looks like one of those magic perl variables, b
ut
> ^^ > [] 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...56a5cb3831212df
> ^^ 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 $_)?
Pursuing backwards compatibility justifies the obfuscation. The lexical
$_ was news in v5.9.1.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Post Follow-up to this message
Quoth abigail@abigail.be:
> _
> Gunnar Hjalmarsson (noreply@gunnar.cc) wrote on VCCCXXVIII September
> MCMXCIII in <URL:news:65i7ejF2f3g2iU1@mid.individual.net>:
> ^^ Abigail wrote:
> ^^ > David Harmon (source@netcom.com) wrote on VCCCXXVIII September MCMXCI
II
> ^^ > in <URL:news:fb6dnc-9EJLmcm_anZ2dnUVZ_rSrnZ2d@earthlink.com>:
> ^^ > [] On Mon, 31 Mar 2008 23:23:25 +0200 in comp.lang.perl.misc, Gunnar
> ^^ > [] Hjalmarsson <noreply@gunnar.cc> wrote,
> ^^ > [] >I do, I hope. :)
> ^^ > [] >
> ^^ > [] > foreach my $num ( 0 .. 0b11111 ) {
> ^^ > [] > local *_ = \ sprintf '%05b', $num;
> ^^ > []
> ^^ > [] What is *_ ? It looks like one of those magic perl variables, b
ut
> ^^ > [] 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...56a5cb3831212df
> ^^ 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
Post Follow-up to this messageOn Wed, 02 Apr 2008 22:20:44 +0200 in comp.lang.perl.misc, Gunnar
Hjalmarsson <noreply@gunnar.cc> wrote,
>As regards applicable docs on _the reason_ why I didn't just say
>
> local $_ = sprintf ...
>
>please see the "Localization of globs" section in "perldoc perlsub".
What I'm wondering is why you didn't use the much simpler (from my
point of view):
foreach my $num ( 0 .. 0b11111 ) {
my $yn = sprintf '%05b', $num;
$yn =~ tr/01/NY/;
print "$yn\n";
}
Doesn't everybody say to prefer lexical over local, unless you
really need local?
Post Follow-up to this messageDavid Harmon wrote:
> On Wed, 02 Apr 2008 22:20:44 +0200 in comp.lang.perl.misc, Gunnar
> Hjalmarsson <noreply@gunnar.cc> wrote,
>
> What I'm wondering is why you didn't use the much simpler (from my
> point of view):
>
> foreach my $num ( 0 .. 0b11111 ) {
> my $yn = sprintf '%05b', $num;
> $yn =~ tr/01/NY/;
> print "$yn\n";
> }
Because ... I was in $_ mode. ;-)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Post Follow-up to this message_
Gunnar Hjalmarsson (noreply@gunnar.cc) wrote on VCCCXXVIII September
MCMXCIII in <URL:news:65iiscF2f9g0cU1@mid.individual.net>:
;; Abigail wrote:
;; > _
;; > Gunnar Hjalmarsson (noreply@gunnar.cc) wrote on VCCCXXVIII September
;; > MCMXCIII in <URL:news:65i7ejF2f3g2iU1@mid.individual.net>:
;; > ^^ Abigail wrote:
;; > ^^ > David Harmon (source@netcom.com) wrote on VCCCXXVIII September MCM
XCIII
;; > ^^ > in <URL:news:fb6dnc-9EJLmcm_anZ2dnUVZ_rSrnZ2d@earthlink.com>:
;; > ^^ > [] On Mon, 31 Mar 2008 23:23:25 +0200 in comp.lang.perl.misc, Gun
nar
;; > ^^ > [] Hjalmarsson <noreply@gunnar.cc> wrote,
;; > ^^ > [] >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 starti
ng
;; > ^^ with
;; > ^^ http://groups.google.com/group/comp...56a5cb3831212df
;; > ^^ 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 $_)?
;;
;; Pursuing backwards compatibility justifies the obfuscation. The lexical
;; $_ was news in v5.9.1.
But "my $foo = sprintf ...;" worked since 5.000.
Or do you think '$foo =~ tr /01/YN/' is the obfuscated version of 'tr /01/YN
/'?
Abigail
--
perl -wle'print"Κυστ_αξοτθες_Πεςμ_Θαγλες"^"\x80"x24'
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.