Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: every combination of Y/N in 5 positions
_
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'

Report this thread to moderator Post Follow-up to this message
Old Post
Abigail
04-03-08 11:15 AM


Re: every combination of Y/N in 5 positions
Abigail 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

Report this thread to moderator Post Follow-up to this message
Old Post
Frank Seitz
04-03-08 11:15 AM


Re: every combination of Y/N in 5 positions
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.

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

Report this thread to moderator Post Follow-up to this message
Old Post
Gunnar Hjalmarsson
04-03-08 11:15 AM


Re: every combination of Y/N in 5 positions
David 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

Report this thread to moderator Post Follow-up to this message
Old Post
Gunnar Hjalmarsson
04-03-08 11:15 AM


Re: every combination of Y/N in 5 positions
_
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 '@}>-`-,-`-%-'

Report this thread to moderator Post Follow-up to this message
Old Post
Abigail
04-03-08 11:15 AM


Re: every combination of Y/N in 5 positions
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 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

Report this thread to moderator Post Follow-up to this message
Old Post
Gunnar Hjalmarsson
04-03-08 11:15 AM


Re: every combination of Y/N in 5 positions
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

Report this thread to moderator Post Follow-up to this message
Old Post
Ben Morrow
04-03-08 11:15 AM


Re: every combination of Y/N in 5 positions
On 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?

Report this thread to moderator Post Follow-up to this message
Old Post
David Harmon
04-03-08 11:15 AM


Re: every combination of Y/N in 5 positions
David 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

Report this thread to moderator Post Follow-up to this message
Old Post
Gunnar Hjalmarsson
04-03-08 11:15 AM


Re: every combination of Y/N in 5 positions
_
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'

Report this thread to moderator Post Follow-up to this message
Old Post
Abigail
04-03-08 11:15 AM


Sponsored Links




Last Thread Next Thread Next
Pages (3): « 1 2 [3]
Search this forum -> 
Post New Thread

PERL Miscellaneous archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 09:55 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.