line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::WolframAlpha::Units; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
15
|
use 5.008008; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
53
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
534
|
use WWW::WolframAlpha::Unit; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
470
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
14
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
15
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# This allows declaration use WWW::WolframAlpha ':all'; |
18
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
19
|
|
|
|
|
|
|
# will save memory. |
20
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
21
|
|
|
|
|
|
|
) ] ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @EXPORT = qw( |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $VERSION = '1.0'; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new { |
32
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
33
|
0
|
|
|
|
|
|
my $xmlo = shift; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $self = {}; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
$self->{'count'} = 0; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my ($count,$unit,$img); |
40
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
if ($xmlo) { |
42
|
0
|
|
0
|
|
|
|
$count = $xmlo->{'count'} || undef; |
43
|
0
|
|
0
|
|
|
|
$unit = $xmlo->{'unit'} || undef; |
44
|
0
|
|
0
|
|
|
|
$img = $xmlo->{'img'} || undef; |
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
|
$self->{'count'} = $count if defined $count; |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
if (defined $unit) { |
49
|
0
|
|
|
|
|
|
@{$self->{'unit'}} = (); |
|
0
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
foreach my $value (@{$unit}) { |
|
0
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
push(@{$self->{'unit'}}, WWW::WolframAlpha::Unit->new($value)); |
|
0
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
if (defined $img) { |
56
|
0
|
|
|
|
|
|
my $html = '
|
57
|
0
|
|
|
|
|
|
foreach my $attr (keys %{$img}) { |
|
0
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
$html .= ' ' . $attr . '=\'' . $img->{$attr} . '\''; |
59
|
|
|
|
|
|
|
} |
60
|
0
|
|
|
|
|
|
$html .= '/>'; |
61
|
0
|
|
|
|
|
|
$self->{'img'} = $html; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
return(bless($self, $class)); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
0
|
0
|
|
sub count {shift->{'count'};} |
71
|
0
|
|
|
0
|
0
|
|
sub unit {shift->{'unit'};} |
72
|
0
|
|
|
0
|
0
|
|
sub img {shift->{'img'};} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Preloaded methods go here. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=pod |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 NAME |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
WWW::WolframAlpha::Units |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 VERSION |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
version 1.10 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 SYNOPSIS |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
if ($info->units->count) { |
93
|
|
|
|
|
|
|
print " units img: ", $info->units->img, "\n" if $info->units->img; |
94
|
|
|
|
|
|
|
foreach my $unit (@{$info->units->unit}) { |
95
|
|
|
|
|
|
|
... |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 DESCRIPTION |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 ATTRIBUTES |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
$units->count |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 SECTOINS |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
$units->unit - array of L elements |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 EXPORT |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
None by default. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 NAME |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
WWW::WolframAlpha::Units - Perl objects returned via $info->units |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 SEE ALSO |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
L |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 AUTHOR |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Gabriel Weinberg, Eyegg@alum.mit.eduE |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Copyright (C) 2009 by Gabriel Weinberg |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
130
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.8 or, |
131
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 AUTHOR |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Gabriel Weinberg |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
This software is copyright (c) 2009 by Gabriel Weinberg. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
142
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
__END__ |