line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Shorten; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
80162
|
use 5.006; |
|
4
|
|
|
|
|
13
|
|
4
|
4
|
|
|
4
|
|
20
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
90
|
|
5
|
4
|
|
|
4
|
|
16
|
use warnings; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
124
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
17
|
use base qw(WWW::Shorten::generic); |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
2740
|
|
8
|
4
|
|
|
4
|
|
18
|
use Carp (); |
|
4
|
|
|
|
|
3
|
|
|
4
|
|
|
|
|
701
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $DEFAULT_SERVICE = 'TinyURL'; |
11
|
|
|
|
|
|
|
our @EXPORT = qw(makeashorterlink makealongerlink); |
12
|
|
|
|
|
|
|
our $VERSION = '3.092'; |
13
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $style; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub import { |
18
|
4
|
|
|
4
|
|
41
|
my $class = shift; |
19
|
4
|
|
|
|
|
7
|
$style = shift; |
20
|
4
|
100
|
|
|
|
18
|
$style = $DEFAULT_SERVICE unless defined $style; |
21
|
4
|
|
|
|
|
9
|
my $package = "${class}::${style}"; |
22
|
4
|
|
|
|
|
5
|
eval { |
23
|
4
|
|
|
|
|
5
|
my $file = $package; |
24
|
4
|
|
|
|
|
14
|
$file =~ s/::/\//g; |
25
|
4
|
|
|
|
|
2102
|
require "$file.pm"; |
26
|
|
|
|
|
|
|
}; |
27
|
4
|
50
|
|
|
|
15
|
Carp::croak($@) if $@; |
28
|
4
|
|
|
|
|
30
|
$package->import(@_); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 NAME |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
WWW::Shorten - Interface to URL shortening sites. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SYNOPSIS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#!/usr/bin/env perl |
40
|
|
|
|
|
|
|
use strict; |
41
|
|
|
|
|
|
|
use warnings; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
use WWW::Shorten 'TinyURL'; # Recommended |
44
|
|
|
|
|
|
|
# use WWW::Shorten 'Linkz'; # or one of the others |
45
|
|
|
|
|
|
|
# use WWW::Shorten 'Shorl'; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Individual modules have have their own syntactic variations. |
48
|
|
|
|
|
|
|
# See the documentation for the particular module you intend to use for details |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $url = 'https://metacpan.org/pod/WWW::Shorten'; |
51
|
|
|
|
|
|
|
my $short_url = makeashorterlink($url); |
52
|
|
|
|
|
|
|
my $long_url = makealongerlink($short_url); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# - OR - |
55
|
|
|
|
|
|
|
# If you don't like the long function names: |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
use WWW::Shorten 'TinyURL', ':short'; |
58
|
|
|
|
|
|
|
my $short_url = short_link($url); |
59
|
|
|
|
|
|
|
my $long_url = long_link( $short_url ); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 DESCRIPTION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
A Perl interface to various services that shorten URLs. These sites maintain |
64
|
|
|
|
|
|
|
databases of long URLs, each of which has a unique identifier. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 COMMAND LINE PROGRAM |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
A very simple program called F is supplied in the |
69
|
|
|
|
|
|
|
distribution's F folder. This program takes a URL and |
70
|
|
|
|
|
|
|
gives you a shortened version of it. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 BUGS, REQUESTS, COMMENTS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Please submit any L you |
75
|
|
|
|
|
|
|
might have. We appreciate all help, suggestions, noted problems, and especially patches. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Note that support for extra shortening services should be released as separate modules, |
78
|
|
|
|
|
|
|
like L or L. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Support for this module is supplied primarily via the using the |
81
|
|
|
|
|
|
|
L but we also |
82
|
|
|
|
|
|
|
happily respond to issues submitted to the |
83
|
|
|
|
|
|
|
L system via the web |
84
|
|
|
|
|
|
|
or email: C |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
* https://github.com/p5-shorten/www-shorten/issues |
87
|
|
|
|
|
|
|
* http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Shorten |
88
|
|
|
|
|
|
|
* ( shorter URL: http://xrl.us/rfb ) |
89
|
|
|
|
|
|
|
* C |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Iain Truskett C |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=over |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item * |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Alex Page -- for the original LWP hacking on which Dave based his code. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item * |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Ask Bjoern Hansen -- providing L |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item * |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Chase Whitener C |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item * |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Dave Cross dave@perlhacks.com -- Authored L on which this was based |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item * |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Eric Hammond -- writing L |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Jon and William (wjr) -- smlnk services |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item * |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Kazuhiro Osawa C |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item * |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Kevin Gilbertson (Gilby) -- TinyURL API information |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item * |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Martin Thurn -- bug fixes |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item * |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Matt Felsen (mattf) -- shorter function names |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item * |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Neil Bowers C |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item * |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
PJ Goodwin -- code for L |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item * |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Shashank Tripathi C -- for providing L |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item * |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Simon Batistoni -- giving the `makealongerlink` idea to Dave. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item * |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Everyone else we might have missed. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=back |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
In 2004 Dave Cross took over the maintenance of this distribution |
162
|
|
|
|
|
|
|
following the death of Iain Truskett. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
In 2016, Chase Whitener took over the maintenance of this distribution. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Copyright (c) 2002 by Iain Truskett. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 SEE ALSO |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
L, L |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |