File: advent_2012_2.pl

package info (click to toggle)
libtest-lwp-useragent-perl 0.036-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 428 kB
  • sloc: perl: 530; makefile: 10
file content (18 lines) | stat: -rw-r--r-- 395 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use strict;
use warnings;
use feature 'say';

use Test::LWP::UserAgent;

my $useragent = Test::LWP::UserAgent->new;
$useragent->network_fallback(1);
$useragent->map_response(qr/example.com/, HTTP::Response->new('200'));

my $response = $useragent->get('http://example.com');
# prints 200
say $response->code;

$response = $useragent->get('http://google.com');
# prints 200
say $response->code;