Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: curl without backticks and system()

by choroba (Archbishop)
on Jan 29, 2017 at 16:52 UTC ( #1180565=note: print w/replies, xml ) Need Help??

in reply to curl without backticks and system()

  1. Using system and backticks might be a security risk if user input is part of the executed command. Tainting and proper validation of user input should be employed to mitigate the risk. In many other situations, it might be just sloppy and slow, as starting a new shell usually takes a lot more than doing the same steps in the already running Perl interpreter. Getting an HTTP header from a remote server and searching for a given detail is easy in Perl. There are still tools that don't have Perl interface, for them using system or backticks is the only way to go.

  2. #!/usr/bin/perl use warnings; use strict; use feature qw{ say }; use LWP::UserAgent; my $url = ''; my $ua = 'LWP::UserAgent'->new; if (my $header = $ua->head($url)) { my ($version) = $header->header('Content-Disposition') =~ /(\d+\.\d+(?:\.\d+ +)?)/; say $version; } else { die "Can't retrieve the header from '$url'.\n"; }

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: curl without backticks and system()
by Anonymous Monk on Jan 31, 2017 at 10:22 UTC
    Fantastic! Thanks for the code, I will have a play at how this performs cross platform, it works on CentOS 7, but will need to test across 5, and 6, Plus Debian and Ubuntu. So far it seems this is what I need. Thanks for helping improve my Perl game and reducing my need to backtick "literally everything" :)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2019-12-09 01:59 GMT
Find Nodes?
    Voting Booth?

    No recent polls found