Skip to content

Instantly share code, notes, and snippets.

@haruki7049
Created December 20, 2024 10:58
Show Gist options
  • Save haruki7049/1ed9d6cc9bfa2f1a7ba927fdca9e0324 to your computer and use it in GitHub Desktop.
Save haruki7049/1ed9d6cc9bfa2f1a7ba927fdca9e0324 to your computer and use it in GitHub Desktop.
An hobby implementation of curl, for learning Perl.
#!/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