NAME
WWW::Pastebin::CSSStandardsOrg::Retrieve - retrieve pastes from http://paste.css-standards.org/ pastebin
SYNOPSIS
use strict;
use warnings;
use WWW::Pastebin::CSSStandardsOrg::Retrieve;
my $paster = WWW::Pastebin::CSSStandardsOrg::Retrieve->new;
my $results = $paster->retrieve('http://paste.css-standards.org/2904')
or die $paster->error;
print "Paste contents:\n$paster\n";
printf "Posted by %s on %s\nDescription: %s\n",
@$results{qw(name posted_on desc)};
DESCRIPTION
The module provides interface to retrieve pastes from http://paste.css-standards.org/ website.
CONSTRUCTOR
new
my $paster = WWW::Pastebin::CSSStandardsOrg::Retrieve->new;
my $paster = WWW::Pastebin::CSSStandardsOrg::Retrieve->new(
timeout => 10,
);
my $paster = WWW::Pastebin::CSSStandardsOrg::Retrieve->new(
ua => LWP::UserAgent->new(
timeout => 10,
agent => 'PasterUA',
),
);
Constructs and returns a brand new yummy juicy WWW::Pastebin::CSSStandardsOrg::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.
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::CSSStandardsOrg::Retrieve
's timeout
argument is set to as well as agent
argument is set to mimic Firefox.
METHODS
retrieve
my $results_ref = $paster->retrieve('http://paste.css-standards.org/2904')
or die $paster->error;
my $results_ref = $paster->retrieve(2904)
or die $paster->error;
Instructs the object to retrieve a specific paste. Takes one mandatory argument which can be either paste's number or a full URI to the paste. On failure returns either undef
or an empty list (depending on the context) and the reason for failure will be available via error()
method. On success returns a hashref with the following keys (if particular piece of data is not present (e.g. name
) it will be set to N/A
):
$VAR1 = {
'content' => '<!DOCTYPE HTML PUBLIC blah blah',
'posted_on' => 'Monday, December 11th, 2006 at 14:38',
'desc' => 'N/A',
'name' => 'makk'
};
content
{ 'content' => '<!DOCTYPE HTML PUBLIC blah blah' }
The content
key will contain the actual content of the paste. Also, see content()
method described below which is overloaded.
posted_on
{ 'posted_on' => 'Monday, December 11th, 2006 at 14:38' }
The posted_on
key will contain the date/time when the paste was created.
desc
{ 'desc' => 'N/A' }
The desc
key will contain the description of the paste.
name
{ 'name' => 'makk' }
The name
key will contain the name of the person who created the paste.
error
$paster->retrieve(2904)
or die $paster->error;
On failure the retrieve()
method returns either undef
or an empty list (depending on the context) and the reason for failure will be available via error()
method. Takes no arguments, returns a human parsable message explaining why retrieve()
failed.
results
my $last_results = $paster->results;
Must be called after a successful call to retrieve()
. Takes no arguments, returns the exact same hashref last call to retrieve()
returned.
content
my $paste_content = $paster->content;
print "Paste contents: $paster\n";
Must be called after a successfull call to retrieve()
. Takes no arguments, returns the content of the paste; in other words, the value of the content
key from the hashref retrieve()
returns. Note: this method is overloaded for this object - you can interpolate the object in a string to aquire paste's contents: print "Paste contents: $paster\n";
uri
my $paste_uri = $paster->uri;
Must be called after a successfull call to retrieve()
. Takes no arguments, returns a URI object pointing to the retrieved paste irrelevant of whether retrieve()
method was given an ID or URI.
id
my $paste_id = $paster->id;
Must be called after a successfull call to retrieve()
. Takes no arguments, returns the ID of retrieved paste irrelevant of whether retrieve()
method was given an ID or URI.
ua
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()
.
SEE ALSO
LWP::UserAgent, URI, http://paste.css-standards.org
AUTHOR
Zoffix Znet, <zoffix at cpan.org>
(http://zoffix.com, http://haslayout.net)
BUGS
Please report any bugs or feature requests to bug-www-pastebin-cssstandardsorg-retrieve at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Pastebin-CSSStandardsOrg-Retrieve. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc WWW::Pastebin::CSSStandardsOrg::Retrieve
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-Pastebin-CSSStandardsOrg-Retrieve
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/WWW-Pastebin-CSSStandardsOrg-Retrieve
CPAN Ratings
http://cpanratings.perl.org/d/WWW-Pastebin-CSSStandardsOrg-Retrieve
Search CPAN
http://search.cpan.org/dist/WWW-Pastebin-CSSStandardsOrg-Retrieve
COPYRIGHT & LICENSE
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.