Created
December 20, 2024 10:58
-
-
Save haruki7049/1ed9d6cc9bfa2f1a7ba927fdca9e0324 to your computer and use it in GitHub Desktop.
An hobby implementation of curl, for learning Perl.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use LWP; | |
use HTTP::Request; | |
my $url = <STDIN>; | |
my $user_agent = LWP::UserAgent->new; | |
$user_agent->agent("perl-curl/0.1 "); | |
my $request = HTTP::Request->new(GET => $url); | |
my $response = $user_agent->request($request); | |
if ($response->is_success) { | |
print $response->content; | |
} else { | |
print $response->status_line, ""; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment