Sure so you should use ? place holders.
Well, doh :) Not using placeholders or a quote function is a beginners mistake - I agree that code like that should be concealed in every possible way.
I have very simple style rules I always try to follow:
- Do not use double quotes (qq//) for SQL queries
- Do not use double quotes for system calls
- Put parameters for system calls in a list, NEVER use backticks with user input (unless very well checked). (use IPC::Open2 or IPC::Open3 if necessary)
- Use 3-argument open when file names are variable (5.6+)
And there are probably some that I can't think of right now. In general, use double quotes only if you need them (I really wonder why books and tutorials and examples like
merlyn's use double quotes most of the time - they imply trouble (in my experience). Trouble with
@-signs, with
's (apostrophes), etcetera etcetera.).
Simple style rules can prevent a lot of trouble. Check for definedness, never use input without checking first. But another good thing is knowing how problems like the code you supplied can be exploited, so you can avoid such stupidity in your own programs.
It's a learning process, but also a matter of self-confidence.
U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk