WWW::WolframAlpha - Perl extension for the WolframAlpha API
use WWW::WolframAlpha; my $wa = WWW::WolframAlpha->new ( appid => 'XXX', ); my $query = $wa->query( input => 'Pi', ); if ($query->success) { foreach my $pod (@{$query->pods}) { ... } }
See the included example.*.pl files for full working examples.
Access to this module is strictly OO. Pass your appid to the constructor, which is the only parameter needed.
There are three functions available, query, validatequery and asyncPod, which match the API calls.
Pass any desired input paramters to the function calls. The 'input' parameter is required.
Each function call returns objects, of the forms WWW::WolframAlpha::Query, WWW::WolframAlpha::ValidateQuery and WWW::WolframAlpha::Pod, respectively.
See the WolframAlpha API docs for details on the overall API, what parameters you can input and what you can expect in response.
All the attributes and elements detailed in the API docs are available via the returned objects. See the documentation in WWW::WolframAlpha::Query, WWW::WolframAlpha::ValidateQuery, WWW::WolframAlpha::Pod and other sub-packages for details on what methods are available for particular objects.
If there are errors contacting WA, $wa->error will be set to 1 and $wa->errmsg should give you some indication of what is going on.
Errors returned by WA are handled within the objects themselves via success and error methods (see example.*.pl files).
For debugging, the raw XML output and the internal Perl object used (via XML::Simple) are available via the xml and xmlo methods. However, please don't rely on these, i.e. only use them for debugging.
None by default.
WWW::WolframAlpha requires XML::Simple, LWP::UserAgent, URI::Escape and HTTP::Request::Common.
http://www.wolframalpha.com/
Gabriel Weinberg, <yegg@alum.mit.edu>
Copyright (C) 2009 by Gabriel Weinberg
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
To install WWW::WolframAlpha, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::WolframAlpha
CPAN shell
perl -MCPAN -e shell install WWW::WolframAlpha
For more information on module installation, please visit the detailed CPAN module installation guide.