Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Counter Intuitive Code

by vr (Curate)
on Mar 27, 2019 at 22:19 UTC ( [id://1231764]=note: print w/replies, xml ) Need Help??


in reply to Counter Intuitive Code

Another alternative would be to tell Perl to DWIM, by putting her into position to use her own brains instead of bothering you to micromanage -- the position is "can't tell string from number? very well, here's no numbers for you but just a string, and don't come back until you figure it out yourself": eval join'|', @ARGV

(it was a joke, btw)

Replies are listed 'Best First'.
Re^2: Counter Intuitive Code
by RonW (Parson) on Mar 31, 2019 at 17:31 UTC
    eval join'|', @ARGV

    While that works, it is dangerous to directly eval user input. eval has the full power of the perl compiler behind it.

    Of course, in this use case, the user is also using the Perl debugger, which is equally dangerous.

    Always remember, tools of great power come with great responsibility.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-03-29 01:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found