- 论坛徽章:
- 0
|
小骆驼中对于这段程序的说明,原话如下
On the other hand, if you were wanted to obfuscate your code (shame on you), you could create a monster like this (shame on us):
That trickier code works in place of the original tricky for loop. You should be able to decipher that one or obfuscate code to amaze your friends and confound your enemies. Use these powers only for good, never for evil.
代码格式整理之后
- for (my $pos = -1;
- -1 != ($pos = index +$string, +$sub, +$pos+1);
- push @places, ((((+$pos)))))
- {
- 'for ($pos != 1; # ;$pos++) {
- print "position $pos\n";#;';#' } pop @places;
- }
复制代码
这段代码就是一个index函数的升级+迷惑版 ,功能也是在$string中寻找$sub出现的$pos并且push到@places数组中。同index不同的一点是,这段代码能够循环查找,如果$string为"work and work again",$sub为"work",则@places的值为0和9。功能完全是通过for循环的头部来实现的,循环体内(花括号内)是一个被丢弃的字符串+注释,完全是迷惑用的 |
|