>>>>> "SF" == Shlomi Fish <shlo...@iglu.org.il> writes:

  SF> On Wednesday 09 Jun 2010 02:43:57 sillymonkeysoftw...@gmail.com wrote:
  >> Hi everyone,
  >> 
  >> I'm working with some customizable data from a config file, and can't
  >> for the life of me figure out how to test conditionals from an
  >> external source.
  >> Does anyone have an idea how to accomplish something like:
  >> 
  >> my $statement = "1 < 10 and 2 > 10";  # obviously false
  >> my $result = ($statement) ? 1 : 0;        # conditional test
  >> 
  >> Now, $result will always be true(1), because the conditional is
  >> really, in effect, just validating that $statement is a defined
  >> scalar, not testing the statement.
  >> But, how can I perform an actual conditional statement on this?
  >> What I really want is:
  >> 
  >> (1 < 10 and 2 > 10) ? 1 : 0;
  >> 

  SF> You can opt to use string eval, but this opens up a lot of security 
problems. 
  SF> Alternatively write your own parser for a mini-language: http://perl-
  SF> begin.org/uses/text-parsing/ .

gack, no need for a parser, mini or otherwise. keep complexity out of
this with a simple table of comparison values. see my other post for
more. if he wants full perl code, then use a dispatch table.

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