|Don't ask to ask, just ask|
curl without backticks and system()by urbansumo (Novice)
|on Jan 29, 2017 at 16:12 UTC||Need Help??|
urbansumo has asked for the wisdom of the Perl Monks concerning the following question:
Someone told me that I should avoid using backticks and system() in my scripts. I therefore come to the gates with a couple of questions:
1. Is using backticks and/or system() really that bad, ie is it ever appropriate to use backticks and what security issues does it pose if you do, or is it just considered sloppy (ie not purist) programming?
2. My specific requirement is the use of curl in order to pull out the latest wordpress version from the header information, for example:
Here is what the $response variable would look like:
This response variable is then passed through a regex filter to return the version number only (4.7.2).
Here is the full subroutine in all its glory:
This works perfectly, however, I'm looking for a way to not have to run system commands to achieve this, but the kicker is, I'm looking to achieve this using only core perl modules, to ensure maximum portability of the code.
I've done a lot of searching for ways to achieve this but hit roadblocks that mean the backticks are here to stay for a while.
Any help you can provide will be gratefully received.