line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::SPOJ; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
WWW::SPOJ - Extract data from Sphere Online Judge (SPOJ) |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use WWW::SPOJ; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $ua = WWW::SPOJ::ua(); |
12
|
|
|
|
|
|
|
$ua->timeout(10); |
13
|
|
|
|
|
|
|
$ua->env_proxy; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $user = new WWW::SPOJ::User('john_jones'); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION AND MOTIVATION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
The Sphere Online Judge, better known by its acronym, SPOJ, is an online |
21
|
|
|
|
|
|
|
archive of programming problems complete with a judge program that receives |
22
|
|
|
|
|
|
|
and checks submissions. Common utilities requested by users of this site |
23
|
|
|
|
|
|
|
include a user head-to-head comparer, a programming language preference |
24
|
|
|
|
|
|
|
analyzer, a user activity grapher, etc. This distribution aims to simplify |
25
|
|
|
|
|
|
|
building those and similar tools by providing modules and functions that |
26
|
|
|
|
|
|
|
retrieve and parse data from SPOJ. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
2
|
|
38632
|
use 5.006; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
292
|
|
31
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
745
|
|
32
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
233
|
|
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
2
|
|
11
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
371
|
|
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
2
|
|
926
|
use WWW::SPOJ::User; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
169
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
our $VERSION = '0.00_01'; |
39
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $ua; |
42
|
|
|
|
|
|
|
my $service = 'http://www.spoj.pl/'; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 FUNCTIONS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=over 4 |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item WWW::SPOJ::ua( [ USER_AGENT ] ) |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Returns the user agent object used for all retrievals, first setting |
51
|
|
|
|
|
|
|
it to USER_AGENT if it's specified. Defaults to a C L. |
52
|
|
|
|
|
|
|
You can customize this object as in the L. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
If you decide to replace the user agent altogether, you don't have to use |
55
|
|
|
|
|
|
|
a L: the only requirement is that the object you use can |
56
|
|
|
|
|
|
|
C a URL and return a response object. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub ua { |
61
|
1
|
50
|
|
1
|
1
|
12
|
if(@_) { |
|
|
50
|
|
|
|
|
|
62
|
0
|
|
|
|
|
0
|
$ua = shift; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
elsif(!defined($ua)) { |
65
|
1
|
|
|
|
|
6
|
eval { |
66
|
1
|
|
|
|
|
1114
|
require LWP::UserAgent; |
67
|
1
|
|
|
|
|
51432
|
$ua = new LWP::UserAgent; |
68
|
|
|
|
|
|
|
}; |
69
|
|
|
|
|
|
|
} |
70
|
1
|
50
|
|
|
|
3590
|
defined($ua) or carp 'Problem setting user agent'; |
71
|
1
|
|
|
|
|
7
|
return $ua; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item WWW::SPOJ::service( [ URL ] ) |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Returns the web address of the service used by this module, first setting |
77
|
|
|
|
|
|
|
it to URL if it's specified. Defaults to L. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=back |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub service { |
84
|
1
|
50
|
|
1
|
1
|
4
|
$service = shift if @_; |
85
|
1
|
|
|
|
|
16
|
return $service; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
__END__ |