in reply to Re^2: Hygienic eval of templates with perl code?
in thread Hygienic eval of templates with perl code?

Wouldn't a package give you readable symbols? e.g.
$Some::Package::foo++; # new var
instead of
my $foo++; # new var
You could also choose a package name in such a way as to reduce the chance of a collision.

Replies are listed 'Best First'.
Re^4: Hygienic eval of templates with perl code?
by LanX (Saint) on Aug 27, 2014 at 22:43 UTC
    > choose a package name in such a way as to reduce the chance of a collision

    That's one of the standard techniques described in wikipedia, but it's not 100% cause it relies on convention.

    And I really prefer lexicals cause there scope is controllable, and I don't need to localize the variables in recursive calls.

    Furthermore a full qualified $Some::Really::Long::Package::foo++ can be so cumbersome that people would like using a placeholder again... maybe $<PCKG>::foo .

    A lexical variation of this package idea would be just one hash $<MyHash>{foo} and to only assure that this hash's name is unique.

    But I admit that in the future I might need to support "safe" package variables for this project too.

    Cheers Rolf

    (addicted to the Perl Programming Language and ☆☆☆☆ :)