bhushanQA has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Here is my requirement, I want to send the Curl command with payload in my perl script, which module I should use and how to use. Basically I want to use POST, PUT and GET methods to access my database and insertion into database and update the database, how can I achieve this. Please suggest.
  • Comment on I wan to send the curl command in perl script.

Replies are listed 'Best First'.
Re: I wan to send the curl command in perl script.
by marto (Cardinal) on Jun 25, 2015 at 06:57 UTC

    It sounds like you're trying to automate a web interface, I suggest you take a look at WWW::Mechanize (and related modules). If you are purely trying to load data into a database there are more sensible ways than this. Most databases provide tools specifically designed for bulk loading, failing that you can quickly knock something up in perl to do this for you. Super Search will likely find you examples of this.

    Update: typos

Re: I wan to send the curl command in perl script.
by robby_dobby (Hermit) on Jun 25, 2015 at 06:47 UTC
    Hello bhushanQA,

    You can do it by invoking curl from perl script via backticks. But I won't recommend you do that. Look at a module like LWP::UserAgent. Good luck.

Re: I wan to send the curl command in perl script.
by Anonymous Monk on Jun 25, 2015 at 06:53 UTC

    Go to MetaCPAN, pick any curl module, click on the name to read the docs, after that you can install the module and try some of the code from the SYNOPSIS or the examples directory

    If it works, great, if it doesn't , report back here

Re: I wan to send the curl command in perl script.
by 1nickt (Canon) on Jun 25, 2015 at 09:36 UTC

    What kind of database?

    Whatever it is, there is almost certainly a module on CPAN for accessing the database and updating it.

    The advantages of using an existing module or modules are too many to list, but among them are:

    • Vastly simpler and easier to maintain code
    • automatic trapping and handling of DB connection errors and other errors