in reply to a not so complex if statment
You need to compile the Perl code in $if, which is what eval EXPR does.
if (eval $if) { print "hi"; } else { print "hello"; }
But in the example you've shown, you're better off just storing a boolean value in $if:
$min = some number if defined $max = some number if defined $Files = some number $IdleTime = some number $if = 0; $if = ($Files >= $max) if defined $max; $if ||= ($IdleTime >= $min) if defined $min; if ($if) { print "hi"; } else { print "hello"; }
Update: When using the eval method, you probably want to use single quotes when building up $if. Let eval do the interpolation.
|
|---|