Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: eval, but syntax-check only -- like perl -c

by dpuu (Chaplain)
on Apr 24, 2003 at 18:57 UTC ( [id://252972]=note: print w/replies, xml ) Need Help??


in reply to eval, but syntax-check only -- like perl -c

Thanks all: I think I'll go with wrapping it in an anonymous sub -- eval will then return something that I can actually run, later, if I want. I'll probably run some rexen on the code to ensure it doesn't contain things like "BEGIN", "CHECK", "use" or named-sub defns. If I overly constrain, then someone will complain and I can fix it later. --Dave

Replies are listed 'Best First'.
Re: Re: eval, but syntax-check only -- like perl -c
by seattlejohn (Deacon) on Apr 25, 2003 at 03:00 UTC
    You're probably aware of this already, but there will still be ways for sneaky programmers to get around restrictions like that. For instance:
    my @backward_chars = ('e', 's', 'u'); my $watch_out = (reverse join "",@backward_chars) . " Data::Dumper;"; eval $watch_out; my $x = Dumper([1,2,3]); print $x;

    I've managed to use Data::Dumper without "use" every appearing explicitly in the code.

    Update: D'oh, I forgot to consider the all-important "wrap in an anonymous subroutine" part, which would seem to defer actual execution of the code. My bad.

            $perlmonks{seattlejohn} = 'John Clyman';

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://252972]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-03-29 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found