Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: your obfuscation magic!

by brx (Pilgrim)
on Apr 24, 2012 at 17:12 UTC ( [id://966904]=note: print w/replies, xml ) Need Help??


in reply to your obfuscation magic!

Nested loops with glob or (very very dirty) regex.

First: for (1..12) { for (1..12) { for (1..12) {...}}}
#!/usr/bin/perl use strict;use warnings; my $num =3; $"=',';print join "\n",glob join "_",("{@{ [1..12] }}")x$num; ___END___ 1_1_1 1_1_2 1_1_3 1_1_4 1_1_5 1_1_6 ... 12_12_7 12_12_8 12_12_9 12_12_10 12_12_11 12_12_12
same thing (without $num param) than:
print join "\n", glob "{1,2,3,4}_{1,2,3,4}_{1_2_3_4}";


Second: for $i (1 .. 12) { for $j ($i+1 .. 12) { for $k ($j+1 .. 12) {...}}}
#!/usr/bin/perl use strict;no strict 'refs';use warnings;use re 'eval'; my $num =3; $"='.*?';"@{ [1..12] }" =~ /@{[ ('\b(\d+)\b')x $num]}(?{{print ((j +oin "_",map {$$_}1..$num),"\n")}})(?!)/; __END__ 1_2_3 1_2_4 1_2_5 1_2_6 1_2_7 ... 8_11_12 9_10_11 9_10_12 9_11_12 10_11_12
same thing (without $num param) than:
"1 2 3 4" =~ /\b(\d+)\b.*?\b(\d+)\b(?{{print "$1_$2\n"}})(?!)/;


Update: $" ($LIST_SEPARATOR) permits "implicit join" (for an array interpolated in a string)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://966904]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-03-29 11:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found