The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WWW::Pastebin::NoPasteCom::Create - create new pastes on http://nopaste.com/ pastebin site

SYNOPSIS

    use strict;
    use warnings;

    use WWW::Pastebin::NoPasteCom::Create;

    my $paster = WWW::Pastebin::NoPasteCom::Create->new;

    $paster->paste('large text to paste')
        or die $paster->error;

    print "Your paste is located on $paster\n";

DESCRIPTION

The module provides interface to paste large texts or files to http://nopaste.com/

CONSTRUCTOR

new

    my $paster = WWW::Pastebin::NoPasteCom::Create->new;

    my $paster = WWW::Pastebin::NoPasteCom::Create->new(
        timeout => 10,
    );

    my $paster = WWW::Pastebin::NoPasteCom::Create->new(
        ua => LWP::UserAgent->new(
            timeout => 10,
            agent   => 'PasterUA',
        ),
    );

Constructs and returns a brand new yummy juicy WWW::Pastebin::NoPasteCom::Create 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 pasting. 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 pasting, 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::NoPasteCom::Create's timeout argument is set to as well as agent argument is set to mimic Firefox.

METHODS

paste

    my $paste_uri = $paster->paste('lots and lots of text')
        or die $paster->error;

    $paster->paste(
        'paste.txt',
        file    => 1,
        nick    => 'Zoffix',
        desc    => 'paste from file',
        lang    => 'perl',
    ) or die $paster->error;

Instructs the object to create a new paste. If an error occured during pasting will return 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 URI object pointing to a newly created paste. The first argument is mandatory and must be either a scalar containing the text to paste or a filename. The rest of the arguments are optional and are passed in a key/value fashion. Possible arguments are as follows:

file

    $paster->paste( 'paste.txt', file => 1 );

Optional. When set to a true value the object will treat the first argument as a filename of the file containing the text to paste. When set to a false value the object will treat the first argument as a scalar containing the text to be pasted. Defaults to: 0

nick

    $paster->paste( 'some text', nick => 'Zoffix' );

Optional. Takes a scalar as a value which specifies the nick of the person creating the paste. Defaults to: empty string (no nick)

desc

    $paster->paste( 'some text', desc => 'some l33t codez' );

Optional. Takes a scalar as a value which specifies the description of the paste. Defaults to: empty string (no description)

lang

    $paster->paste( 'some text', lang => 'perl' );

Optional. Takes a scalar as a value which must be one of predefined language codes and specifies (computer) language of the paste, in other words which syntax highlighting to use. Defaults to: plain. Valid language codes are as follows (case insensitive):

    c
    html
    pascal
    plain
    rhtml
    ruby
    xml

error

    my $paste_uri = $paster->paste('lots and lots of text')
        or die $paster->error;

If an error occured during the call to paste() it will return 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 a human parsable error message explaining why we failed.

paste_uri

    my $last_paste_uri = $paster->paste_uri;

    print "Paste can be found on $paster\n";

Must be called after a successfull call to paste(). Takes no arguments, returns a URI object pointing to a paste created by the last call to paste(), i.e. the return value of the last paste() call. This method is overloaded as q|"" thus you can simply interpolate your object in a string to obtain the paste 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 pating. Takes one optional argument which must be an LWP::UserAgent object, and the object you specify will be used in any subsequent calls to paste().

AUTHOR

Zoffix Znet, <zoffix at cpan.org> (http://zoffix.com, http://haslayout.net, http://zofdesign.com/)

BUGS

Please report any bugs or feature requests to bug-www-pastebin-nopastecom-create at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Pastebin-NoPasteCom-Create. 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::NoPasteCom::Create

You can also look for information at:

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.