>>>>> "TB" == Thomas Bätzler <t.baetz...@bringe.com> writes:

  TB> You can do something like

  TB>   my $cond = eval( $statement );

  TB> The two important things to keep in mind:

  TB> 1) Make sure you sanitize $statement very carefully. Otherwise people can 
run arbitrary perl commands and you probably don't want that.

  TB> 2) Check $@       after calling eval to see wether the code could be 
executed or wether it caused an error.

you forgot to tell him not to use eval unless it is absolutely
needed. it is a lazy and as you say dangerous solution. it is the last
thing you should want to do in many cases where there are many safer
solutions (and i posted some already).

rule: never suggest eval string unless there is no other way. especially
to newbies who will abuse it royally.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to