NAME

WWW::Pastebin::Sprunge::Retrieve - retrieves pastes from the sprunge.us pastebin

VERSION

version 0.008

SYNOPSIS

use strict;
use warnings;
use WWW::Pastebin::Sprunge::Retrieve;
my $paster = WWW::Pastebin::Sprunge::Retrieve->new();
my $content = $paster->retrieve('http://sprunge.us/84Pc') or die $paster->error();
print $content; # overloaded

DESCRIPTION

The module provides an interface to retrieve pastes from the http://sprunge.us pastebin website via Perl.

METHODS

new

my $paster = WWW::Pastebin::Sprunge::Retrieve->new();
# OR:
my $paster = WWW::Pastebin::Sprunge::Retrieve->new(
    timeout => 10,
);
# OR:
my $paster = WWW::Pastebin::Sprunge::Retrieve->new(
    ua => LWP::UserAgent->new(
        timeout => 10,
        agent   => 'PasterUA',
    ),
);

Constructs and returns a new WWW::Pastebin::Sprunge::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!' ) );

If the timeout argument is not enough for your needs, 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: a LWP::UserAgent object with timeout argument set to 30s, and a suitable useragent string.

retrieve

my $content = $paster->retrieve('http://sprunge.us/SCLg') or die $paster->error();

my $content = $paster->retrieve('SCLg') 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 the pasted text.

error

$paster->retrieve('SCLg')
    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.

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 string as 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.

AVAILABILITY

The project homepage is http://metacpan.org/release/WWW-Pastebin-Sprunge/.

The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit http://www.perl.com/CPAN/ to find a CPAN site near you, or see https://metacpan.org/module/WWW::Pastebin::Sprunge/.

SOURCE

The development version is on github at http://github.com/doherty/WWW-Pastebin-Sprunge and may be cloned from git://github.com/doherty/WWW-Pastebin-Sprunge.git

BUGS AND LIMITATIONS

You can make new bug reports, and view existing ones, through the web interface at https://github.com/doherty/WWW-Pastebin-Sprunge/issues.

AUTHOR

Mike Doherty <doherty@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2010 by Mike Doherty.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.