| 1 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | package WWW::Shorten::Yahooit; | ||
| 4 | { | ||
| 5 | $WWW::Shorten::Yahooit::VERSION = '0.004'; | ||
| 6 | } | ||
| 7 | 2 | ▶ | use base qw( WWW::Shorten::generic Exporter ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | our @EXPORT = qw( makeashorterlink makealongerlink ); | ||
| 9 | 0 | ▶ | use WWW::YQL; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 10 | use Carp; | ||
| 11 | |||
| 12 | # ABSTRACT: Perl interface to y.ahoo.it | ||
| 13 | # PODNAME: WWW::Shorten::Yahooit | ||
| 14 | |||
| 15 | |||
| 16 | |||
| 17 | sub makeashorterlink{ | ||
| 18 | my $url = shift or croak 'No URL passed to makeashorterlink'; | ||
| 19 | my $yql = WWW::YQL->new(); | ||
| 20 | |||
| 21 | my $data = $yql->query("insert into yahoo.y.ahoo.it (url) values ('".$url."')"); | ||
| 22 | if (defined $data->{'query'}->{'results'}->{'error'}){ | ||
| 23 | die $data->{'query'}->{'results'}->{'error'}; | ||
| 24 | }else{ | ||
| 25 | return $data->{'query'}->{'results'}->{'url'}; | ||
| 26 | } | ||
| 27 | } | ||
| 28 | |||
| 29 | sub makealongerlink{ | ||
| 30 | my $url = shift or croak 'No URL passed to makeashorterlink'; | ||
| 31 | my $yql = WWW::YQL->new(); | ||
| 32 | my $data = $yql->query("select * from yahoo.y.ahoo.it where url='".$url."'"); | ||
| 33 | if (defined $data->{'query'}->{'results'}->{'error'}){ | ||
| 34 | die $data->{'query'}->{'results'}->{'error'}; | ||
| 35 | }else{ | ||
| 36 | return $data->{'query'}->{'results'}->{'url'}; | ||
| 37 | } | ||
| 38 | } | ||
| 39 | 1; | ||
| 40 | |||
| 41 | __END__ | ||