curl2lwp - convert Curl command line arguments to LWP / Mechanize Perl code

After inspiration by a comment on and some slight hacking, I'm very proud to announce HTTP::Request::FromCurl, together with its companion online site at The module and included curl2lwp program allow you to easily convert curl command lines to Perl code that uses LWP::UserAgent resp. WWW::Mechanize.

Some code: -X GET -A xpcurl/1.0

outputs the following code:

    my $ua = WWW::Mechanize->new();
    my $r = HTTP::Request->new(
        'GET' => '',
            'Accept' => '*/*',
            'Host' => '',
            'User-Agent' => 'curl/1.0',
    my $res = $ua->request( $r,  );

The online version creates a bit more code, as the output there is likely not consumed by advanced Perl programmers.

The module parses a subset of the valid curl command lines and generates equivalent code for LWP::UserAgent for it. Support for other HTTP user agents Mojo::UserAgent, AnyEvent::HTTP, Future::HTTP ) is not yet implemented but I welcome contributions there.

The app driving the online interface is not yet released onto CPAN, but as it is mostly HTML scaffolding and some Javascript, it should be released fairly soon.

Leave a comment

About Max Maischein

user-pic I'm the Treasurer for the Frankfurt Perlmongers e.V. . I have organized Perl events including 9 German Perl Workshops and one YAPC::Europe.