in reply to Re^4: Bad code from the trenches
in thread Bad code from the trenches

yes, it's called eval STRING :-)

Replies are listed 'Best First'.
Re^6: Bad code from the trenches
by dragonchild (Archbishop) on Mar 14, 2005 at 14:16 UTC
    I meant "accidentally". eval STRING is rarely done by accident. :-)

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

      There is no other way to force it, except the usual things that imply eval, like writing the string to a file and then require()ing it, using the string in the replacement part of a s///e expression, etc.

      Note that the (?{ code }) constructs in regexes are also safe from interpolation in /$regex/ except when you explicitly use re 'eval'

        Note that the (?{ code }) constructs in regexes are also safe from interpolation in /$regex/ except when you explicitly use re 'eval'
        But that wasn't originally the case when that feature was first to be released. I argued with Ilya for a few rounds on P5P, then decided he wasn't listening. He kept saying "but they should untaint their regex" like that was even possible by mortals.

        So I simply took the position that I would personally and immediately file a CERT bug against Perl 5.00X (whatever it was) the moment it came out. Oddly enough, he "invented" "use re 'eval'" about a day after that. {grin}

        -- Randal L. Schwartz, Perl hacker
        Be sure to read my standard disclaimer if this is a reply.