Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: input special characters

by Anonymous Monk
on Jul 13, 2014 at 15:30 UTC ( [id://1093435]=note: print w/replies, xml ) Need Help??


in reply to Re^2: input special characters
in thread input special characters

If you decided to use eval, you should really consider this:
# file eval.pl use strict; use warnings; my $sep = shift @ARGV; my $evaled = eval "qq/$sep/"; print "$evaled:\n"
Now the user enters this:
perl eval.pl 'hehe/; print "Hello there!\n"; unlink "./eval.pl"; q/foo +'
Result:
Useless use of a constant ("hehe") in void context at (eval 1) line 1. Hello there! foo:
And the eval.pl file is gone. So, yeah... as I said, eval is usually more trouble than it's worth. Maybe consider module Safe, which provides restricted eval, if you're dealing with users there (users are evil).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-24 17:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found