Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Configurable comparisons

by mobiGeek (Beadle)
on Feb 27, 2002 at 04:53 UTC ( [id://147814]=note: print w/replies, xml ) Need Help??


in reply to Configurable comparisons

Just answering the question as asked.

It's not complicated, but don't look at the extra backslashes and '$' and think you can ignore them...the key is to understand them.

my $status = "false"; do_eval( "status", "eq", "false" ); do_eval( "status", "eq", "true" ); sub do_eval { my ($var, $op, $val) = @_; print "\$$var $op \"$val\": "; eval "if(\$$var $op \"$val\") {print 'Equal';} else{print 'Not';}"; print "\n"; }

Replies are listed 'Best First'.
Re: Re: Configurable comparisons
by dash2 (Hermit) on Feb 27, 2002 at 13:18 UTC
    No reason why you shouldn't answer the question as asked but be sure to point out the extreme vulnerability in the code.

    For example, suppose param('op') is and exec 'rm -rf /' and . This will then evaluate if ($status and exec 'rm -rf /' and "true") ..., which will attempt to wipe all files on your machine.

    dave hj~

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2024-05-21 14:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found