WWW::Pastebin::PastebinCa::Retrieve - a module to retrieve pastes from http://pastebin.ca/ website
Due to the change on the pastebin, as of version 0.003, the description of the paste is available, while the "age" is no longer.
my $paster = WWW::Pastebin::PastebinCa::Retrieve->new; $paster->retrieve('http://pastebin.ca/951898') or die $paster->error; print "Paste content is:\n$paster\n";
The module provides interface to retrieve pastes from http://pastebin.ca/ website via Perl.
new
my $paster = WWW::Pastebin::PastebinCa::Retrieve->new; my $paster = WWW::Pastebin::PastebinCa::Retrieve->new( timeout => 10, ); my $paster = WWW::Pastebin::PastebinCa::Retrieve->new( ua => LWP::UserAgent->new( timeout => 10, agent => 'PasterUA', ), );
Constructs and returns a brand new juicy WWW::Pastebin::PastebinCa::Retrieve object. Takes two arguments, both are optional. Possible arguments are as follows:
timeout
->new( timeout => 10 );
Optional. Specifies the timeout argument of LWP::UserAgent's constructor, which is used for retrieving. Defaults to: 30 seconds.
30
ua
->new( ua => LWP::UserAgent->new( agent => 'Foos!' ) );
Optional. If the timeout argument is not enough for your needs of mutilating the LWP::UserAgent object used for retrieving, feel free to specify the ua argument which takes an LWP::UserAgent object as a value. Note: the timeout argument to the constructor will not do anything if you specify the ua argument as well. Defaults to: plain boring default LWP::UserAgent object with timeout argument set to whatever WWW::Pastebin::PastebinCa::Retrieve's timeout argument is set to as well as agent argument is set to mimic Firefox.
WWW::Pastebin::PastebinCa::Retrieve
agent
retrieve
my $results_ref = $paster->retrieve('http://pastebin.ca/951898') or die $paster->error; my $results_ref = $paster->retrieve('951898') or die $paster->error;
Instructs the object to retrieve a paste specified in the argument. Takes one mandatory argument which can be either a full URI to the paste you want to retrieve or just its ID. On failure returns either undef or an empty list depending on the context and the reason for the error will be available via error() method. On success returns a hashref with the following keys/values:
undef
error()
$VAR1 = { 'language' => 'Raw', 'content' => 'blah blah content of the paste', 'post_date' => 'Friday, March 21st, 2008 at 1:05:19pm MDT', 'name' => 'Unnamed', 'desc' => 'Perl stuff' };
{ 'language' => 'Raw' }
The (computer) language of the paste.
{ 'content' => 'select t.terr_id, max(t.start_date) as start_dat' }
The content of the paste.
{ 'post_date' => 'Wednesday, March 5th, 2008 at 10:31:42pm MST' }
The date when the paste was created
{ 'name' => 'Mine' }
Tha name of the poster or the title of the paste.
{ 'desc' => 'Perl stuff' }
Contains description of the paste.
error
$paster->retrieve('951898') or die $paster->error;
On failure retrieve() returns either undef or an empty list depending on the context and the reason for the error will be available via error() method. Takes no arguments, returns an error message explaining the failure.
retrieve()
id
my $paste_id = $paster->id;
Must be called after a successful call to retrieve(). Takes no arguments, returns a paste ID number of the last retrieved paste irrelevant of whether an ID or a URI was given to retrieve()
uri
my $paste_uri = $paster->uri;
Must be called after a successful call to retrieve(). Takes no arguments, returns a URI object with the URI pointing to the last retrieved paste irrelevant of whether an ID or a URI was given to retrieve()
results
my $last_results_ref = $paster->results;
Must be called after a successful call to retrieve(). Takes no arguments, returns the exact same hashref the last call to retrieve() returned. See retrieve() method for more information.
content
my $paste_content = $paster->content; print "Paste content is:\n$paster\n";
Must be called after a successful call to retrieve(). Takes no arguments, returns the actual content of the paste. Note: this method is overloaded for this module for interpolation. Thus you can simply interpolate the object in a string to get the contents of the paste.
my $old_LWP_UA_obj = $paster->ua; $paster->ua( LWP::UserAgent->new( timeout => 10, agent => 'foos' );
Returns a currently used LWP::UserAgent object used for retrieving pastes. Takes one optional argument which must be an LWP::UserAgent object, and the object you specify will be used in any subsequent calls to retrieve().
LWP::UserAgent, URI
Zoffix Znet, <zoffix at cpan.org> (http://zoffix.com, http://haslayout.net, http://mind-power-book.com)
<zoffix at cpan.org>
Please report any bugs or feature requests to bug-www-pastebin-pastebinca-retrieve at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Pastebin-PastebinCa-Retrieve. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-www-pastebin-pastebinca-retrieve at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc WWW::Pastebin::PastebinCa::Retrieve
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-Pastebin-PastebinCa-Retrieve
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/WWW-Pastebin-PastebinCa-Retrieve
CPAN Ratings
http://cpanratings.perl.org/d/WWW-Pastebin-PastebinCa-Retrieve
Search CPAN
http://search.cpan.org/dist/WWW-Pastebin-PastebinCa-Retrieve
Copyright 2008 Zoffix Znet, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install WWW::Pastebin::PastebinCa::Retrieve, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::Pastebin::PastebinCa::Retrieve
CPAN shell
perl -MCPAN -e shell install WWW::Pastebin::PastebinCa::Retrieve
For more information on module installation, please visit the detailed CPAN module installation guide.