|
Posted by Willem on April 1, 2008, 11:38 am
Please log in for more thread options
Abigail wrote:
) But that doesn't print newlines after each entry.
Oh right, I missed the -l flag. Sorry.
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
|
|
Posted by Robbie Hatley on April 1, 2008, 11:34 pm
Please log in for more thread options
Gunnar Hjalmarsson wrote:
> ... it's easy to write obfuscated code using Perl...
> perl -le"dofor(0..0b11111)"
Huh. That doesn't look "obfuscated" to me at all. I read "write $_
back to itself as a 0-padded 5-position binary field, transliterate
01 to NY, print, repeat for $_ = 0 through 31". Outputs "NNNNN"
through "YYYYY", each on its own line.
(As a newbie Perl programmer, I don't know whether the fact that the
above one-liner doesn't seem "obfuscated" to me should make me happy
or terrified. Perhaps a little of both.)
Maybe you're using the wrong language. Try C for obfuscation:
#include <stdio.h>
main(t,_,a)char* a;\
{return!0<t?t<3?main(-79,-13,a+main(-87,1-_,\
main(-86, 0, a+1 )+a)):1,t<_?main(t+1, _, a ):3,main ( -94, -27+t, a\
)&&t == 2 ?_<13 ?main ( 2, _+1, "%s %d %d\n" ):9:16:t<0?t<-72?main(_,\
t,"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+\
,/+#n+,/#;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l q#'+d'K#!/\
+k#;q#'r}eKK#}w'r}eKKw')rw' i;# ){n\
l]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#\
n'wk nw' iwk{KK{nl]!/w{%'l##w#' i; :'c \
;;rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;\
#'rdq#w! nr'/ ') }+}{rl#'{n' ')# }'+}##(!!/")\
:t<-50?_==*a ?putchar(a[31]):main(-65,_,a+1):main((*a == '/')+t,_,a\
+1 ):0<t?main ( 2, 2 , "%s"):*a=='/'||main(0,main(-61,*a, "!ek;dc \
i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}
(Note: I'm not the author of that.)
Compile that with a C compiler and run it. You'll be amazed at what
it does. Ho, ho, ho! Merry Christmas! Or Merry April Fools Day,
as the case may be.
BONUS PROBLEM FOR PERL HACKERS HERE: Translate the above C program
into Perl... and be sure you make it just as obfuscated! (I tried,
but didn't get very far; trying to figure it out gave me a headache.
The fact that main calls itself recursively in 11 different places
is enough to fill me with horror.)
--
Cheers,
Robbie Hatley
lonewolf aatt well dott com
www dott well dott com slant user slant lonewolf slant
|
|
Posted by Peter J. Holzer on April 9, 2008, 1:14 pm
Please log in for more thread options > Gunnar Hjalmarsson wrote:
>> ... it's easy to write obfuscated code using Perl...
>> perl -le"dofor(0..0b11111)"
>
> Huh. That doesn't look "obfuscated" to me at all.
Nor to me. Except for the lack of whitespace and possibly the
reassignement to $_, that's pretty readable.
> (As a newbie Perl programmer, I don't know whether the fact that the
> above one-liner doesn't seem "obfuscated" to me should make me happy
> or terrified. Perhaps a little of both.)
>
> Maybe you're using the wrong language. Try C for obfuscation:
[...]
Somebody once said that there is no Obfuscated Perl Code Contest because
it would be pointless. He was wrong on both counts: Firstly, writing
"obfus" ist a favorite pastime of some perl programmers, and there are
contests (although AFAIK there is no global, annual contest like the
OCCC), and secondly, not all (or even most) Perl code is obfuscated. It
is perfectly possible to write sane, readable Perl code. But it is also
possible to write code which is even more obfuscated in Perl than in C
(for once, Perl code can modify itself, which (portable) C can't).
For a beautiful (and rather famous) example, of a Perl obfu, see
http://www.perlmonks.org/index.pl?node=camel code
hp
|
|
Posted by A. Sinan Unur on April 9, 2008, 4:21 pm
Please log in for more thread options
> For a beautiful (and rather famous) example, of a Perl obfu, see
> http://www.perlmonks.org/index.pl?node=camel code
ITYM:
http://www.perlmonks.org/index.pl?node=camel%20code
Sinan
--
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
|
|
Posted by David Harmon on April 1, 2008, 10:28 pm
Please log in for more thread options 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.
|
| Similar Threads | Posted | | Looking for combination.pm | June 29, 2005, 10:56 pm |
| Perl + Objects = Winning combination | April 9, 2007, 7:55 pm |
| Perl Developer Positions in California | March 11, 2005, 12:53 pm |
| htaccess rewriterule in combination with POST form | January 28, 2005, 12:38 am |
| How can I add tokens at arbitrary positions on a line in a file? | August 13, 2005, 6:36 am |
|