line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Acme::Rando; |
2
|
|
|
|
|
|
|
$Acme::Rando::VERSION = '0.1'; |
3
|
2
|
|
|
2
|
|
32437
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
62
|
|
4
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
42
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1777
|
use HTTP::Tiny; |
|
2
|
|
|
|
|
87944
|
|
|
2
|
|
|
|
|
83
|
|
7
|
2
|
|
|
2
|
|
1372
|
use JSON; |
|
2
|
|
|
|
|
27322
|
|
|
2
|
|
|
|
|
11
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1538
|
use parent 'Exporter'; |
|
2
|
|
|
|
|
610
|
|
|
2
|
|
|
|
|
13
|
|
10
|
|
|
|
|
|
|
our @EXPORT = qw(rando); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Acme::Rando - Get a Random Star Wars quote |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 VERSION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
version 0.1 |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use Acme::Rando; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
say rando(); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Exports a function rando() which returns a random star wars quote. This joke |
31
|
|
|
|
|
|
|
probably only makes sense to my coworkers. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub rando { |
36
|
12
|
|
|
12
|
0
|
887
|
my $res = HTTP::Tiny->new->get('http://www.iheartquotes.com/api/v1/random?source=starwars&format=json'); |
37
|
|
|
|
|
|
|
|
38
|
12
|
50
|
|
|
|
2200898
|
unless ($res->{success}) { |
39
|
0
|
|
|
|
|
0
|
return "These aren't the droids you're looking for: $res->{reason}" |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
12
|
|
|
|
|
208
|
my $dat = JSON::decode_json($res->{content}); |
43
|
|
|
|
|
|
|
|
44
|
12
|
|
|
|
|
162
|
return $dat->{quote}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 AUTHORS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Chris Reinhardt |
50
|
|
|
|
|
|
|
crein@cpan.org |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 COPYRIGHT |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This program is free software; you can redistribute |
55
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
The full text of the license can be found in the |
58
|
|
|
|
|
|
|
LICENSE file included with this module. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
__END__ |