line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Shorten; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
260729
|
use 5.008001; |
|
4
|
|
|
|
|
41
|
|
4
|
4
|
|
|
4
|
|
22
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
100
|
|
5
|
4
|
|
|
4
|
|
37
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
139
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
20
|
use base qw(WWW::Shorten::generic); |
|
4
|
|
|
|
|
19
|
|
|
4
|
|
|
|
|
1822
|
|
8
|
4
|
|
|
4
|
|
26
|
use Carp (); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
712
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $DEFAULT_SERVICE = 'TinyURL'; |
11
|
|
|
|
|
|
|
our @EXPORT = qw(makeashorterlink makealongerlink); |
12
|
|
|
|
|
|
|
our $VERSION = '3.094'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $style; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub import { |
17
|
4
|
|
|
4
|
|
49
|
my $class = shift; |
18
|
4
|
|
|
|
|
8
|
$style = shift; |
19
|
4
|
100
|
|
|
|
16
|
$style = $DEFAULT_SERVICE unless defined $style; |
20
|
4
|
|
|
|
|
12
|
my $package = "${class}::${style}"; |
21
|
4
|
|
|
|
|
9
|
eval { |
22
|
4
|
|
|
|
|
8
|
my $file = $package; |
23
|
4
|
|
|
|
|
20
|
$file =~ s/::/\//g; |
24
|
4
|
|
|
|
|
1892
|
require "$file.pm"; |
25
|
|
|
|
|
|
|
}; |
26
|
4
|
50
|
|
|
|
21
|
Carp::croak($@) if $@; |
27
|
4
|
|
|
|
|
31
|
$package->import(@_); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 NAME |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
WWW::Shorten - Interface to URL shortening sites. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 SYNOPSIS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#!/usr/bin/env perl |
39
|
|
|
|
|
|
|
use strict; |
40
|
|
|
|
|
|
|
use warnings; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
use WWW::Shorten 'TinyURL'; # Recommended |
43
|
|
|
|
|
|
|
# use WWW::Shorten 'Bitly'; # or one of the others |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Individual modules have have their own syntactic variations. |
46
|
|
|
|
|
|
|
# See the documentation for the particular module you intend to use for details |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $url = 'https://metacpan.org/pod/WWW::Shorten'; |
49
|
|
|
|
|
|
|
my $short_url = makeashorterlink($url); |
50
|
|
|
|
|
|
|
my $long_url = makealongerlink($short_url); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# - OR - |
53
|
|
|
|
|
|
|
# If you don't like the long function names: |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
use WWW::Shorten 'TinyURL', ':short'; |
56
|
|
|
|
|
|
|
my $short_url = short_link($url); |
57
|
|
|
|
|
|
|
my $long_url = long_link( $short_url ); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 DESCRIPTION |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
A Perl interface to various services that shorten URLs. These sites maintain |
62
|
|
|
|
|
|
|
databases of long URLs, each of which has a unique identifier. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 DEPRECATION NOTICE |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
The following shorten services have been deprecated as the endpoints no longer |
67
|
|
|
|
|
|
|
exist or function: |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=over |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item * |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
L |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item * |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
L |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item * |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
L |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item * |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
L |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item * |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
L |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item * |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
L |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item * |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
L |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item * |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
L |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=back |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
When version C<3.100> is released, these deprecated services will not be part of |
106
|
|
|
|
|
|
|
the distribution. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 SHORTEN APP |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
A very simple program called F is supplied in the |
111
|
|
|
|
|
|
|
distribution's F folder. This program takes a URL and |
112
|
|
|
|
|
|
|
gives you a shortened version of it. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 BUGS, REQUESTS, COMMENTS |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Please submit any L you |
117
|
|
|
|
|
|
|
might have. We appreciate all help, suggestions, noted problems, and especially patches. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
* If you know of a shorten service that we don't already have, make your own |
120
|
|
|
|
|
|
|
service and release it as a separate module, like L or |
121
|
|
|
|
|
|
|
L. Alternatively, you can let us know and we'll be happy |
122
|
|
|
|
|
|
|
to work it up for you. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 AUTHOR |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Iain Truskett C |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=over |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item * |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Alex Page -- for the original LWP hacking on which Dave based his code. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item * |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Ask Bjoern Hansen -- providing L |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item * |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Chase Whitener C |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item * |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Dave Cross dave@perlhacks.com -- Authored L on which this was based |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item * |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Eric Hammond -- writing L |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item * |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Jon and William (wjr) -- smlnk services |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item * |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Kazuhiro Osawa C |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item * |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Kevin Gilbertson (Gilby) -- TinyURL API information |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item * |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Martin Thurn -- bug fixes |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item * |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Matt Felsen (mattf) -- shorter function names |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item * |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Neil Bowers C |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=item * |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
PJ Goodwin -- code for L |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=item * |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Shashank Tripathi C -- for providing L |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=item * |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Simon Batistoni -- giving the `makealongerlink` idea to Dave. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=item * |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Everyone else we might have missed. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=back |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
In 2004 Dave Cross took over the maintenance of this distribution |
195
|
|
|
|
|
|
|
following the death of Iain Truskett. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
In 2016, Chase Whitener took over the maintenance of this distribution. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
Copyright (c) 2002 by Iain Truskett. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 SEE ALSO |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
L, L |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=cut |