I agree with Corion and with a lot of others here: trying to obfuscate your source code is futile. There are laws to protect your IP, use them instead of resorting to that kind of silly trick:
Anyway, I thought your problem was a good fit for Dominus'Memoize, so here it is:
#!/bin/perl -w use strict; use Memoize; memoize('rvg'); # now all calls to rvg are m +emoized my @rnd_names= qw( foo bar baz); $/=""; while(<DATA>) { s/(?<!\\)(\$\w+(?![\[{\w]))/rvg($1)/ge; # need to add $1 for memoize +to know which calls to memoize print; } sub rvg { return shift @rnd_names; } __DATA__ $v1= $v2; $v2++; $v3{$v1}= $v2;
Note that the underlying mechanism is essentially the same as in japhy's solution, Memoize just handles it for you.
In reply to Re: loop/substitution problem
by mirod
in thread loop/substitution problem
by cghost23
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |