blib/lib/WWW/Shorten/Yahooit.pm

filter: Statementstmt 83.3% 10 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 87.5% 14 / 16 CC 1 SCAR 0.7
CC
1
Cov
83%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
↑ Summary
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__
↑ Summary