line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::WolframAlpha::Query; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
18
|
use 5.008008; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
65
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use WWW::WolframAlpha::Assumptions; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
10
|
1
|
|
|
1
|
|
718
|
use WWW::WolframAlpha::Sources; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
11
|
1
|
|
|
1
|
|
671
|
use WWW::WolframAlpha::Pod; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
45
|
|
12
|
1
|
|
|
1
|
|
5
|
use WWW::WolframAlpha::Warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
13
|
1
|
|
|
1
|
|
538
|
use WWW::WolframAlpha::Didyoumeans; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
14
|
1
|
|
|
1
|
|
5
|
use WWW::WolframAlpha::Error; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1120
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
19
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
20
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# This allows declaration use WWW::WolframAlpha ':all'; |
23
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
24
|
|
|
|
|
|
|
# will save memory. |
25
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
26
|
|
|
|
|
|
|
) ] ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our @EXPORT = qw( |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
our $VERSION = '1.0'; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
36
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my %options = @_; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $self = {}; |
41
|
0
|
|
|
|
|
|
while(my($key, $val) = each %options) { |
42
|
0
|
|
|
|
|
|
my $lkey = lc($key); |
43
|
0
|
|
|
|
|
|
$self->{$lkey} = $val; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my ($timing,$parsetiming,$numpods,$assumptions,$pods,$timedout,$datatypes,$css,$scripts,$sources,$warnings,$didyoumeans,$success,$error); |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
@{$self->{'assumptions'}} = (); |
|
0
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
@{$self->{'pods'}} = (); |
|
0
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
@{$self->{'sources'}} = (); |
|
0
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
@{$self->{'warnings'}} = (); |
|
0
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
@{$self->{'didyoumeans'}} = (); |
|
0
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
$self->{'success'} = 0; |
55
|
0
|
|
|
|
|
|
$self->{'error'} = 1; |
56
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
|
if ($self->{'xmlo'}) { |
58
|
0
|
|
0
|
|
|
|
$timing = $self->{'xmlo'}->{'timing'} || undef; |
59
|
0
|
|
0
|
|
|
|
$parsetiming = $self->{'xmlo'}->{'parsetiming'} || undef; |
60
|
0
|
|
0
|
|
|
|
$numpods = $self->{'xmlo'}->{'numpods'} || undef; |
61
|
0
|
|
0
|
|
|
|
$assumptions = $self->{'xmlo'}->{'assumptions'} || undef; |
62
|
0
|
|
0
|
|
|
|
$pods = $self->{'xmlo'}->{'pod'} || undef; |
63
|
0
|
|
0
|
|
|
|
$timedout = $self->{'xmlo'}->{'timedout'} || undef; |
64
|
0
|
|
0
|
|
|
|
$datatypes = $self->{'xmlo'}->{'datatypes'} || undef; |
65
|
0
|
|
0
|
|
|
|
$css = $self->{'xmlo'}->{'css'} || undef; |
66
|
0
|
|
0
|
|
|
|
$scripts = $self->{'xmlo'}->{'scripts'} || undef; |
67
|
0
|
|
0
|
|
|
|
$sources = $self->{'xmlo'}->{'sources'} || undef; |
68
|
0
|
|
0
|
|
|
|
$warnings = $self->{'xmlo'}->{'warnings'} || undef; |
69
|
0
|
|
0
|
|
|
|
$didyoumeans = $self->{'xmlo'}->{'didyoumeans'} || undef; |
70
|
0
|
|
0
|
|
|
|
$success = $self->{'xmlo'}->{'success'} || undef; |
71
|
0
|
|
0
|
|
|
|
$error = $self->{'xmlo'}->{'error'} || undef; |
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
|
$self->{'timing'} = $timing if defined $timing; |
74
|
0
|
0
|
|
|
|
|
$self->{'parsetiming'} = $parsetiming if defined $parsetiming; |
75
|
0
|
0
|
|
|
|
|
$self->{'numpods'} = $numpods if defined $numpods; |
76
|
0
|
0
|
|
|
|
|
$self->{'timedout'} = $timedout if defined $timedout; |
77
|
0
|
0
|
|
|
|
|
$self->{'datatypes'} = $datatypes if defined $datatypes; |
78
|
0
|
0
|
|
|
|
|
$self->{'css'} = $css if defined $css; |
79
|
0
|
0
|
|
|
|
|
$self->{'scripts'} = $scripts if defined $scripts; |
80
|
|
|
|
|
|
|
|
81
|
0
|
0
|
0
|
|
|
|
if (defined $success && $success eq 'true') { |
82
|
0
|
|
|
|
|
|
$self->{'success'} = 1; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
0
|
0
|
|
|
|
if (defined $error && $error eq 'false') { |
|
|
0
|
0
|
|
|
|
|
86
|
0
|
|
|
|
|
|
$self->{'error'} = 0; |
87
|
|
|
|
|
|
|
} elsif (defined $error && $error ne 'false') { |
88
|
0
|
|
|
|
|
|
$self->{'error'} = WWW::WolframAlpha::Error->new($error); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
foreach my $pod (@{$pods}) { |
|
0
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
push(@{$self->{'pods'}}, WWW::WolframAlpha::Pod->new($pod)); |
|
0
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
$self->{'assumptions'} = WWW::WolframAlpha::Assumptions->new($assumptions); |
98
|
0
|
|
|
|
|
|
$self->{'sources'} = WWW::WolframAlpha::Sources->new($sources); |
99
|
0
|
|
|
|
|
|
$self->{'warnings'} = WWW::WolframAlpha::Warnings->new($warnings); |
100
|
0
|
|
|
|
|
|
$self->{'didyoumeans'} = WWW::WolframAlpha::Didyoumeans->new($didyoumeans); |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
return(bless($self, $class)); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
0
|
0
|
|
sub xml {shift->{'xml'};} |
106
|
0
|
|
|
0
|
0
|
|
sub success {shift->{'success'};} |
107
|
0
|
|
|
0
|
0
|
|
sub error {shift->{'error'};} |
108
|
0
|
|
|
0
|
0
|
|
sub xmlo {shift->{'xmlo'};} |
109
|
0
|
|
|
0
|
0
|
|
sub timing {shift->{'timing'};} |
110
|
0
|
|
|
0
|
0
|
|
sub parsetiming {shift->{'parsetiming'};} |
111
|
0
|
|
|
0
|
0
|
|
sub assumptions {shift->{'assumptions'};} |
112
|
0
|
|
|
0
|
0
|
|
sub numpods {shift->{'numpods'};} |
113
|
0
|
|
|
0
|
0
|
|
sub pods {shift->{'pods'};} |
114
|
0
|
|
|
0
|
0
|
|
sub timedout {shift->{'timedout'};} |
115
|
0
|
|
|
0
|
0
|
|
sub datatypes {shift->{'datatypes'};} |
116
|
0
|
|
|
0
|
0
|
|
sub css {shift->{'css'};} |
117
|
0
|
|
|
0
|
0
|
|
sub scripts {shift->{'scripts'};} |
118
|
0
|
|
|
0
|
0
|
|
sub sources {shift->{'sources'};} |
119
|
0
|
|
|
0
|
0
|
|
sub warnings {shift->{'warnings'};} |
120
|
0
|
|
|
0
|
0
|
|
sub didyoumeans {shift->{'didyoumeans'};} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# Preloaded methods go here. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=pod |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 NAME |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
WWW::WolframAlpha::Query |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 VERSION |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
version 1.10 |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 SYNOPSIS |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
my $query = $wa->query( |
140
|
|
|
|
|
|
|
input => $input, |
141
|
|
|
|
|
|
|
assumption => '*C.pi-_*Movie-', |
142
|
|
|
|
|
|
|
); |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
if ($query->success) { |
145
|
|
|
|
|
|
|
foreach my $pod (@{$query->pods}) { |
146
|
|
|
|
|
|
|
if (!$pod->error) { |
147
|
|
|
|
|
|
|
foreach my $subpod (@{$pod->subpods}) { |
148
|
|
|
|
|
|
|
... |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
if ($query->warnings->count) { |
154
|
|
|
|
|
|
|
... |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 DESCRIPTION |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 SUCCESS |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
$query->success - 0/1, tells whether it was successful or not |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
$query->error - 0 or L, tells whether there was an error or not |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head2 ATTRIBUTES |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
$query->timing |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
$query->parsetiming |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
$query->timedout |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
$query->numpods |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
$query->css |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
$query->scripts |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
$query->datatypes |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head2 SECTOINS |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
$query->pods - array of L elements |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
$query->assumptions - L object |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
$query->warnings - L object |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
$query->sources - L object |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
$query->didyoumeans - L object |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head2 DEBUGGING |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
$query->xml - raw XML |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
$query->xmlo - raw XML::Simple object |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head2 EXPORT |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
None by default. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 NAME |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
WWW::WolframAlpha::Query - Perl object returned via $wa->query |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head1 SEE ALSO |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
L |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head1 AUTHOR |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Gabriel Weinberg, Eyegg@alum.mit.eduE |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Copyright (C) 2009 by Gabriel Weinberg |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
222
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.8 or, |
223
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=head1 AUTHOR |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
Gabriel Weinberg |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
This software is copyright (c) 2009 by Gabriel Weinberg. |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
234
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=cut |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
__END__ |