| 1 | package App::Pastebin::sprunge; | ||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 4 | ▶ | use v5.10.1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | # ABSTRACT: application for pasting to and reading from sprunge.us | ||||||||||
| 7 | 4 | our $VERSION = '0.012'; # VERSION | |||||||||
| 8 | |||||||||||
| 9 | |||||||||||
| 10 | 3 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 11 | 3 | my $class = shift; | |||||||||
| 12 | |||||||||||
| 13 | 3 | my $self; | |||||||||
| 14 | 3 | ▶ | if (@ARGV) { # READ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | 1 | $self->{paste_id} = shift @ARGV; | |||||||||
| 16 | 1 | require WWW::Pastebin::Sprunge::Retrieve; | |||||||||
| 17 | 1 | $self->{reader} = WWW::Pastebin::Sprunge::Retrieve->new(); | |||||||||
| 18 | } | ||||||||||
| 19 | else { # WRITE | ||||||||||
| 20 | 2 | require WWW::Pastebin::Sprunge::Create; | |||||||||
| 21 | 2 | $self->{writer} = WWW::Pastebin::Sprunge::Create->new(); | |||||||||
| 22 | } | ||||||||||
| 23 | 3 | return bless $self, $class; | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | |||||||||||
| 27 | 2 | ▶ | sub run { | ||||||||
|
Subroutine
run: called CC=4 SCAR=14.8
Pod
documented
| |||||||||||
| 28 | 2 | my $self = shift; | |||||||||
| 29 | 2 | my $lang = shift; | |||||||||
| 30 | |||||||||||
| 31 | 2 | ▶ | if ($self->{paste_id}) { # READ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | $self->{reader}->retrieve($self->{paste_id}) | ||||||||||
| 33 | 1 | ▶ | or die "Reading paste $self->{paste_id} failed: ", $self->{reader}->error(); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 0 | say $self->{reader}; | |||||||||
| 35 | } | ||||||||||
| 36 | else { # WRITE | ||||||||||
| 37 | 1 | my $text = do { local $/; <STDIN> }; | |||||||||
| 38 | $self->{writer}->paste($text, lang => $lang) | ||||||||||
| 39 | 1 | ▶ | or die 'Paste failed: ', $self->{writer}->error(); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 0 | say $self->{writer}; | |||||||||
| 41 | } | ||||||||||
| 42 | 0 | return; | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 4 | 1; | |||||||||
| 46 | |||||||||||
| 47 | __END__ | ||||||||||