File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 1717 }
1818}
1919
20- print $response -> {content } if defined $response -> {content };
20+ print $response -> {content } if length $response -> {content };
2121
Original file line number Diff line number Diff line change 1+ # !/usr/bin/perl
2+
3+ use strict;
4+ use warnings;
5+
6+ use HTTP::Tiny;
7+ use URI::Escape qw/ uri_escape_utf8/ ;
8+
9+ my $url = ' http://search.cpan.org/search' ;
10+
11+ my %form_data = (
12+ query => ' DAGOLDEN' ,
13+ mode => ' author' ,
14+ );
15+
16+ my @params ;
17+ while ( my @pair = each %form_data ) {
18+ push @params , join (" =" , map { uri_escape_utf8($_ ) } @pair );
19+ }
20+
21+ my $response = HTTP::Tiny-> new-> request(' POST' , $url , {
22+ content => join (" &" , @params ),
23+ headers => { ' content-type' => ' application/x-www-form-urlencoded' }
24+ });
25+
26+ print " $response ->{status} $response ->{reason}\n " ;
27+
28+ print $response -> {content };
29+
You can’t perform that action at this time.
0 commit comments