in reply to Execute commands in a string

Use eval "perl code" to execute arbitrary Perl code and prepend the string with "package Whatever;" to enforce it being evaluated in the given package.

Replies are listed 'Best First'.
Re^2: Execute commands in a string
by PodMaster (Abbot) on Aug 15, 2004 at 20:02 UTC
    Enforce? I don't think so :)
    $code = 'package Enforce::NOT; sub you; sub cannot;'; eval "package Whatever; $code";

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.