in reply to loop/substitution problem
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.
|
|---|