| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package WWW::Pastebin::PastebinCom::API; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 2 |  |  | 2 |  | 66840 | use strict; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 48 |  | 
| 4 | 2 |  |  | 2 |  | 8 | use warnings; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 63 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | our $VERSION = '1.001004'; # VERSION | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 2 |  |  | 2 |  | 569 | use LWP::UserAgent; | 
|  | 2 |  |  |  |  | 32499 |  | 
|  | 2 |  |  |  |  | 43 |  | 
| 9 | 2 |  |  | 2 |  | 12 | use Carp; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 157 |  | 
| 10 | 2 |  |  | 2 |  | 534 | use HTTP::Cookies; | 
|  | 2 |  |  |  |  | 5052 |  | 
|  | 2 |  |  |  |  | 52 |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 | 2 |  |  | 2 |  | 9 | use base qw/Class::Data::Accessor/; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 554 |  | 
| 13 |  |  |  |  |  |  | __PACKAGE__->mk_classaccessors(qw/ | 
| 14 |  |  |  |  |  |  | error | 
| 15 |  |  |  |  |  |  | api_key | 
| 16 |  |  |  |  |  |  | user_key | 
| 17 |  |  |  |  |  |  | paste_url | 
| 18 |  |  |  |  |  |  | _ua | 
| 19 |  |  |  |  |  |  | /); | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | use overload q|""| => sub { | 
| 22 | 3 |  |  | 3 |  | 1101 | my $obj = shift; | 
| 23 | 3 | 100 |  |  |  | 10 | defined $obj->error ? 'Error: ' . $obj->error : $obj->paste_url | 
| 24 | 2 |  |  | 2 |  | 508 | }; | 
|  | 2 |  |  |  |  | 2 |  | 
|  | 2 |  |  |  |  | 16 |  | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | sub new { | 
| 27 | 1 |  |  | 1 | 1 | 163477 | my $class = shift; | 
| 28 | 1 | 50 |  |  |  | 7 | croak 'Must have even number of arguments to the constructor' | 
| 29 |  |  |  |  |  |  | if @_ & 1; | 
| 30 |  |  |  |  |  |  |  | 
| 31 | 1 |  |  |  |  | 5 | my %args = @_; | 
| 32 | 1 |  |  |  |  | 20 | $args{ +lc } = delete $args{ $_ } for keys %args; | 
| 33 |  |  |  |  |  |  |  | 
| 34 | 1 | 50 |  |  |  | 4 | unless ( $args{timeout} ) { | 
| 35 | 0 |  |  |  |  | 0 | $args{timeout} = 30; | 
| 36 |  |  |  |  |  |  | } | 
| 37 | 1 | 50 |  |  |  | 4 | unless ( $args{ua} ) { | 
| 38 |  |  |  |  |  |  | $args{ua} = LWP::UserAgent->new( | 
| 39 |  |  |  |  |  |  | timeout => $args{timeout}, | 
| 40 | 1 |  |  |  |  | 12 | agent   => 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:21.0)' | 
| 41 |  |  |  |  |  |  | . ' Gecko/20100101 Firefox/21.0', | 
| 42 |  |  |  |  |  |  | ); | 
| 43 |  |  |  |  |  |  | } | 
| 44 |  |  |  |  |  |  |  | 
| 45 | 1 |  |  |  |  | 2308 | my $self = bless {}, $class; | 
| 46 | 1 |  |  |  |  | 7 | $self->_ua( $args{ua} ); | 
| 47 | 1 |  |  |  |  | 45 | $self->api_key( $args{api_key} ); | 
| 48 | 1 |  |  |  |  | 8 | $self->user_key( $args{user_key} ); | 
| 49 |  |  |  |  |  |  |  | 
| 50 | 1 |  |  |  |  | 8 | return $self; | 
| 51 |  |  |  |  |  |  | } | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | sub get_user_info { | 
| 54 | 1 |  |  | 1 | 1 | 646 | my $self = shift; | 
| 55 | 1 |  |  |  |  | 4 | $self->error( undef ); | 
| 56 |  |  |  |  |  |  |  | 
| 57 | 1 | 50 |  |  |  | 7 | my $api_key = $self->_get_api_key | 
| 58 |  |  |  |  |  |  | or return $self->_set_error(q|Missing API key|); | 
| 59 |  |  |  |  |  |  |  | 
| 60 | 1 | 50 |  |  |  | 12 | my $user_key = $self->_get_user_key | 
| 61 |  |  |  |  |  |  | or return $self->_set_error( | 
| 62 |  |  |  |  |  |  | q|Missing USER key. See ->get_user_key() method| | 
| 63 |  |  |  |  |  |  | ); | 
| 64 |  |  |  |  |  |  |  | 
| 65 | 1 |  |  |  |  | 13 | my $response = $self->_ua->post( | 
| 66 |  |  |  |  |  |  | 'http://pastebin.com/api/api_post.php', | 
| 67 |  |  |  |  |  |  | { | 
| 68 |  |  |  |  |  |  | api_dev_key         => $api_key, | 
| 69 |  |  |  |  |  |  | api_user_key        => $user_key, | 
| 70 |  |  |  |  |  |  | api_option          => 'userdetails', | 
| 71 |  |  |  |  |  |  | }, | 
| 72 |  |  |  |  |  |  | ); | 
| 73 |  |  |  |  |  |  |  | 
| 74 | 1 | 50 | 33 |  |  | 203842 | if ( $response->is_success or $response->is_redirect ) { | 
| 75 | 1 | 50 |  |  |  | 17 | return $self->_set_error( $response->content ) | 
| 76 |  |  |  |  |  |  | if $response->content =~ /^Bad API request/; | 
| 77 |  |  |  |  |  |  |  | 
| 78 | 1 |  |  |  |  | 15 | return $self->_parse_user_xml( $response->content ); | 
| 79 |  |  |  |  |  |  | } | 
| 80 |  |  |  |  |  |  | else { | 
| 81 | 0 |  |  |  |  | 0 | $self->error( $response->status_line ); | 
| 82 | 0 |  |  |  |  | 0 | return; | 
| 83 |  |  |  |  |  |  | } | 
| 84 |  |  |  |  |  |  | } | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | sub list_user_pastes { | 
| 87 | 0 |  |  | 0 | 1 | 0 | my $self = shift; | 
| 88 | 0 |  | 0 |  |  | 0 | my $limit = shift || 50; | 
| 89 | 0 | 0 |  |  |  | 0 | $limit = 1    if $limit < 1; | 
| 90 | 0 | 0 |  |  |  | 0 | $limit = 1000 if $limit > 1000; | 
| 91 |  |  |  |  |  |  |  | 
| 92 | 0 |  |  |  |  | 0 | $self->error( undef ); | 
| 93 |  |  |  |  |  |  |  | 
| 94 | 0 | 0 |  |  |  | 0 | my $api_key = $self->_get_api_key | 
| 95 |  |  |  |  |  |  | or return $self->_set_error(q|Missing API key|); | 
| 96 |  |  |  |  |  |  |  | 
| 97 | 0 | 0 |  |  |  | 0 | my $user_key = $self->_get_user_key | 
| 98 |  |  |  |  |  |  | or return $self->_set_error( | 
| 99 |  |  |  |  |  |  | q|Missing USER key. See ->get_user_key() method| | 
| 100 |  |  |  |  |  |  | ); | 
| 101 |  |  |  |  |  |  |  | 
| 102 | 0 |  |  |  |  | 0 | my $response = $self->_ua->post( | 
| 103 |  |  |  |  |  |  | 'http://pastebin.com/api/api_post.php', | 
| 104 |  |  |  |  |  |  | { | 
| 105 |  |  |  |  |  |  | api_dev_key         => $api_key, | 
| 106 |  |  |  |  |  |  | api_user_key        => $user_key, | 
| 107 |  |  |  |  |  |  | api_results_limit   => $limit, | 
| 108 |  |  |  |  |  |  | api_option          => 'list', | 
| 109 |  |  |  |  |  |  | }, | 
| 110 |  |  |  |  |  |  | ); | 
| 111 |  |  |  |  |  |  |  | 
| 112 | 0 | 0 | 0 |  |  | 0 | if ( $response->is_success or $response->is_redirect ) { | 
| 113 | 0 | 0 |  |  |  | 0 | return $self->_set_error( $response->content ) | 
| 114 |  |  |  |  |  |  | if $response->content =~ /^Bad API request/; | 
| 115 |  |  |  |  |  |  |  | 
| 116 | 0 | 0 |  |  |  | 0 | return [] | 
| 117 |  |  |  |  |  |  | if $response->content =~ /^No pastes found/; | 
| 118 |  |  |  |  |  |  |  | 
| 119 | 0 |  |  |  |  | 0 | return $self->_parse_xml( $response->content ); | 
| 120 |  |  |  |  |  |  | } | 
| 121 |  |  |  |  |  |  | else { | 
| 122 | 0 |  |  |  |  | 0 | $self->error( $response->status_line ); | 
| 123 | 0 |  |  |  |  | 0 | return; | 
| 124 |  |  |  |  |  |  | } | 
| 125 |  |  |  |  |  |  | } | 
| 126 |  |  |  |  |  |  |  | 
| 127 |  |  |  |  |  |  | sub list_trends { | 
| 128 | 1 |  |  | 1 | 1 | 1162 | my $self = shift; | 
| 129 |  |  |  |  |  |  |  | 
| 130 | 1 |  |  |  |  | 12 | $self->error( undef ); | 
| 131 |  |  |  |  |  |  |  | 
| 132 | 1 | 50 |  |  |  | 10 | my $api_key = $self->_get_api_key | 
| 133 |  |  |  |  |  |  | or return $self->_set_error(q|Missing API key|); | 
| 134 |  |  |  |  |  |  |  | 
| 135 | 1 |  |  |  |  | 13 | my $response = $self->_ua->post( | 
| 136 |  |  |  |  |  |  | 'http://pastebin.com/api/api_post.php', | 
| 137 |  |  |  |  |  |  | { | 
| 138 |  |  |  |  |  |  | api_dev_key         => $api_key, | 
| 139 |  |  |  |  |  |  | api_option          => 'trends', | 
| 140 |  |  |  |  |  |  | }, | 
| 141 |  |  |  |  |  |  | ); | 
| 142 |  |  |  |  |  |  |  | 
| 143 | 1 | 50 | 33 |  |  | 111521 | if ( $response->is_success or $response->is_redirect ) { | 
| 144 | 1 | 50 |  |  |  | 18 | return $self->_set_error( $response->content ) | 
| 145 |  |  |  |  |  |  | if $response->content =~ /^Bad API request/; | 
| 146 |  |  |  |  |  |  |  | 
| 147 | 1 |  |  |  |  | 18 | return $self->_parse_xml( $response->content ); | 
| 148 |  |  |  |  |  |  | } | 
| 149 |  |  |  |  |  |  | else { | 
| 150 | 0 |  |  |  |  | 0 | $self->error( $response->status_line ); | 
| 151 | 0 |  |  |  |  | 0 | return; | 
| 152 |  |  |  |  |  |  | } | 
| 153 |  |  |  |  |  |  | } | 
| 154 |  |  |  |  |  |  |  | 
| 155 |  |  |  |  |  |  | sub delete_paste { | 
| 156 | 0 |  |  | 0 | 1 | 0 | my $self       = shift; | 
| 157 | 0 |  |  |  |  | 0 | my $paste_key  = shift; | 
| 158 |  |  |  |  |  |  |  | 
| 159 | 0 |  |  |  |  | 0 | $paste_key =~ s{(?:https?://)?(?:www\.)?pastebin\.com/}{}i; | 
| 160 |  |  |  |  |  |  |  | 
| 161 | 0 | 0 | 0 |  |  | 0 | return $self->_set_error('Missing paste key') | 
| 162 |  |  |  |  |  |  | unless defined $paste_key and length $paste_key; | 
| 163 |  |  |  |  |  |  |  | 
| 164 | 0 |  |  |  |  | 0 | $self->error( undef ); | 
| 165 |  |  |  |  |  |  |  | 
| 166 | 0 | 0 |  |  |  | 0 | my $api_key = $self->_get_api_key | 
| 167 |  |  |  |  |  |  | or return $self->_set_error(q|Missing API key|); | 
| 168 |  |  |  |  |  |  |  | 
| 169 | 0 | 0 |  |  |  | 0 | my $user_key = $self->_get_user_key | 
| 170 |  |  |  |  |  |  | or return $self->_set_error( | 
| 171 |  |  |  |  |  |  | q|Missing USER key. See ->get_user_key() method| | 
| 172 |  |  |  |  |  |  | ); | 
| 173 |  |  |  |  |  |  |  | 
| 174 | 0 |  |  |  |  | 0 | my $response = $self->_ua->post( | 
| 175 |  |  |  |  |  |  | 'http://pastebin.com/api/api_post.php', | 
| 176 |  |  |  |  |  |  | { | 
| 177 |  |  |  |  |  |  | # mandatory API keys | 
| 178 |  |  |  |  |  |  | api_dev_key         => $api_key, | 
| 179 |  |  |  |  |  |  | api_user_key        => $user_key, | 
| 180 |  |  |  |  |  |  | api_paste_key       => $paste_key, | 
| 181 |  |  |  |  |  |  | api_option          => 'delete', | 
| 182 |  |  |  |  |  |  | }, | 
| 183 |  |  |  |  |  |  | ); | 
| 184 |  |  |  |  |  |  |  | 
| 185 | 0 | 0 | 0 |  |  | 0 | if ( $response->is_success or $response->is_redirect ) { | 
| 186 | 0 | 0 |  |  |  | 0 | return $self->_set_error( $response->content ) | 
| 187 |  |  |  |  |  |  | if $response->content =~ /^Bad API request/; | 
| 188 |  |  |  |  |  |  |  | 
| 189 | 0 |  |  |  |  | 0 | return 1; | 
| 190 |  |  |  |  |  |  | } | 
| 191 |  |  |  |  |  |  | else { | 
| 192 | 0 |  |  |  |  | 0 | $self->error( $response->status_line ); | 
| 193 | 0 |  |  |  |  | 0 | return; | 
| 194 |  |  |  |  |  |  | } | 
| 195 | 0 |  |  |  |  | 0 | return 1; | 
| 196 |  |  |  |  |  |  | } | 
| 197 |  |  |  |  |  |  |  | 
| 198 |  |  |  |  |  |  | sub get_paste { | 
| 199 | 3 |  |  | 3 | 1 | 1713 | my $self       = shift; | 
| 200 | 3 |  |  |  |  | 6 | my $paste_key  = shift; | 
| 201 | 3 |  |  |  |  | 23 | my ( $login, $pass ) = @_; | 
| 202 |  |  |  |  |  |  |  | 
| 203 | 3 |  |  |  |  | 11 | $self->error( undef ); | 
| 204 |  |  |  |  |  |  |  | 
| 205 | 3 |  |  |  |  | 43 | $paste_key =~ s{(?:https?://)?(?:www\.)?pastebin\.com/}{}i; | 
| 206 |  |  |  |  |  |  |  | 
| 207 | 3 | 50 | 33 |  |  | 25 | defined $paste_key and length $paste_key | 
| 208 |  |  |  |  |  |  | or return $self->_set_error('Missing paste ID or URL'); | 
| 209 |  |  |  |  |  |  |  | 
| 210 | 3 | 100 | 66 |  |  | 21 | if ( defined $login and defined $pass ) { | 
| 211 | 1 |  |  |  |  | 4 | $self->_ua->cookie_jar( HTTP::Cookies->new ); | 
| 212 | 1 |  |  |  |  | 120 | $self->_ua->post( | 
| 213 |  |  |  |  |  |  | 'http://pastebin.com/login.php', { | 
| 214 |  |  |  |  |  |  | submit_hidden   => 'submit_hidden', | 
| 215 |  |  |  |  |  |  | user_name       => $login, | 
| 216 |  |  |  |  |  |  | user_password   => $pass, | 
| 217 |  |  |  |  |  |  | submit          => 'Login', | 
| 218 |  |  |  |  |  |  | } | 
| 219 |  |  |  |  |  |  | ); | 
| 220 |  |  |  |  |  |  | } | 
| 221 |  |  |  |  |  |  |  | 
| 222 | 3 |  |  |  |  | 115049 | my $response = $self->_ua->get( | 
| 223 |  |  |  |  |  |  | "http://pastebin.com/raw.php?i=$paste_key", | 
| 224 |  |  |  |  |  |  | ); | 
| 225 |  |  |  |  |  |  |  | 
| 226 | 3 |  |  |  |  | 848980 | $self->_ua->cookie_jar( undef ); | 
| 227 |  |  |  |  |  |  |  | 
| 228 | 3 | 50 | 33 |  |  | 266 | if ( $response->is_success or $response->is_redirect ) { | 
| 229 | 3 | 50 | 33 |  |  | 79 | return $self->_set_error(q|This paste doesn't exist|) | 
| 230 |  |  |  |  |  |  | unless defined $response->content | 
| 231 |  |  |  |  |  |  | and length $response->content; | 
| 232 |  |  |  |  |  |  |  | 
| 233 | 3 | 100 |  |  |  | 76 | return $self->_set_error( $response->content ) | 
| 234 |  |  |  |  |  |  | if $response->content | 
| 235 |  |  |  |  |  |  | eq 'Error, this is a private paste. If this is your ' | 
| 236 |  |  |  |  |  |  | . 'private paste, please login to Pastebin first.'; | 
| 237 |  |  |  |  |  |  |  | 
| 238 | 2 |  |  |  |  | 21 | return $response->content; | 
| 239 |  |  |  |  |  |  | } | 
| 240 |  |  |  |  |  |  | else { | 
| 241 | 0 | 0 |  |  |  | 0 | if ( $response->status_line eq '404 Not Found' ) { | 
| 242 | 0 |  |  |  |  | 0 | $self->error(q|This paste doesn't exist|); | 
| 243 |  |  |  |  |  |  | } | 
| 244 |  |  |  |  |  |  | else { | 
| 245 | 0 |  |  |  |  | 0 | $self->error( 'Network error: ' . $response->status_line ); | 
| 246 |  |  |  |  |  |  | } | 
| 247 | 0 |  |  |  |  | 0 | return; | 
| 248 |  |  |  |  |  |  | } | 
| 249 |  |  |  |  |  |  | } | 
| 250 |  |  |  |  |  |  |  | 
| 251 |  |  |  |  |  |  | sub paste { | 
| 252 | 1 |  |  | 1 | 1 | 1768 | my $self       = shift; | 
| 253 | 1 |  |  |  |  | 3 | my $paste_text = shift; | 
| 254 |  |  |  |  |  |  |  | 
| 255 | 1 |  |  |  |  | 5 | $self->error( undef ); | 
| 256 | 1 |  |  |  |  | 7 | $self->paste_url( undef ); | 
| 257 |  |  |  |  |  |  |  | 
| 258 | 1 | 50 | 33 |  |  | 12 | defined $paste_text and length $paste_text | 
| 259 |  |  |  |  |  |  | or return $self->_set_error('Paste text is empty'); | 
| 260 |  |  |  |  |  |  |  | 
| 261 | 1 |  |  |  |  | 5 | my %args = @_; | 
| 262 | 1 |  |  |  |  | 8 | $args{ +lc } = delete $args{ $_ } for keys %args; | 
| 263 |  |  |  |  |  |  |  | 
| 264 | 1 | 50 |  |  |  | 4 | my @args = $self->_prepare_optional_api_options( \%args ) | 
| 265 |  |  |  |  |  |  | or return; | 
| 266 |  |  |  |  |  |  |  | 
| 267 | 1 | 50 |  |  |  | 3 | my $api_key = $self->_get_api_key | 
| 268 |  |  |  |  |  |  | or return $self->_set_error(q|Missing API key|); | 
| 269 |  |  |  |  |  |  |  | 
| 270 | 1 |  |  |  |  | 10 | my $response = $self->_ua->post( | 
| 271 |  |  |  |  |  |  | 'http://pastebin.com/api/api_post.php', | 
| 272 |  |  |  |  |  |  | { | 
| 273 |  |  |  |  |  |  | # mandatory API keys | 
| 274 |  |  |  |  |  |  | api_dev_key    => $api_key, | 
| 275 |  |  |  |  |  |  | api_option     => 'paste', | 
| 276 |  |  |  |  |  |  | api_paste_code => $paste_text, | 
| 277 |  |  |  |  |  |  |  | 
| 278 |  |  |  |  |  |  | @args, | 
| 279 |  |  |  |  |  |  | }, | 
| 280 |  |  |  |  |  |  | ); | 
| 281 |  |  |  |  |  |  |  | 
| 282 | 1 | 50 | 33 |  |  | 227172 | if ( $response->is_success or $response->is_redirect ) { | 
| 283 | 1 | 50 |  |  |  | 23 | return $self->_set_error( $response->content ) | 
| 284 |  |  |  |  |  |  | if $response->content =~ /^Bad API request|^Post limit, maximum pastes/; | 
| 285 |  |  |  |  |  |  |  | 
| 286 | 1 |  |  |  |  | 44 | return $self->paste_url( $response->content ); | 
| 287 |  |  |  |  |  |  | } | 
| 288 |  |  |  |  |  |  | else { | 
| 289 | 0 |  |  |  |  | 0 | $self->error( $response->status_line ); | 
| 290 | 0 |  |  |  |  | 0 | return; | 
| 291 |  |  |  |  |  |  | } | 
| 292 |  |  |  |  |  |  | } | 
| 293 |  |  |  |  |  |  |  | 
| 294 |  |  |  |  |  |  | sub get_user_key { | 
| 295 | 1 |  |  | 1 | 1 | 1275 | my ( $self, $login, $pass ) = @_; | 
| 296 |  |  |  |  |  |  |  | 
| 297 | 1 |  |  |  |  | 5 | $self->error( undef ); | 
| 298 | 1 |  |  |  |  | 7 | $self->user_key( undef ); | 
| 299 |  |  |  |  |  |  |  | 
| 300 | 1 | 50 |  |  |  | 6 | my $api_key = $self->_get_api_key | 
| 301 |  |  |  |  |  |  | or return $self->_set_error(q|Missing API key|); | 
| 302 |  |  |  |  |  |  |  | 
| 303 | 1 |  |  |  |  | 11 | my $response = $self->_ua->post( | 
| 304 |  |  |  |  |  |  | 'http://pastebin.com/api/api_login.php', | 
| 305 |  |  |  |  |  |  | { | 
| 306 |  |  |  |  |  |  | api_dev_key         => $api_key, | 
| 307 |  |  |  |  |  |  | api_user_name       => $login, | 
| 308 |  |  |  |  |  |  | api_user_password   => $pass, | 
| 309 |  |  |  |  |  |  | }, | 
| 310 |  |  |  |  |  |  | ); | 
| 311 |  |  |  |  |  |  |  | 
| 312 | 1 | 50 | 33 |  |  | 221931 | if ( $response->is_success or $response->is_redirect ) { | 
| 313 | 1 | 50 |  |  |  | 14 | return $self->_set_error( $response->content ) | 
| 314 |  |  |  |  |  |  | if $response->content =~ /^Bad API request/; | 
| 315 |  |  |  |  |  |  |  | 
| 316 | 1 |  |  |  |  | 14 | return $self->user_key( $response->content ); | 
| 317 |  |  |  |  |  |  | } | 
| 318 |  |  |  |  |  |  | else { | 
| 319 | 0 |  |  |  |  | 0 | $self->error( $response->status_line ); | 
| 320 | 0 |  |  |  |  | 0 | return; | 
| 321 |  |  |  |  |  |  | } | 
| 322 |  |  |  |  |  |  | } | 
| 323 |  |  |  |  |  |  |  | 
| 324 |  |  |  |  |  |  | sub _parse_user_xml { | 
| 325 | 1 |  |  | 1 |  | 9 | my ( $self, $content ) = @_; | 
| 326 |  |  |  |  |  |  |  | 
| 327 | 1 |  |  |  |  | 50 | $content =~ s{\s*(.+)\s*}{$1}gs; | 
| 328 |  |  |  |  |  |  |  | 
| 329 | 1 |  |  |  |  | 21 | my %user = $content =~ ( m{<([^>]+)>(.*?)\1>}sg ); | 
| 330 | 1 |  |  |  |  | 16 | $user{ substr $_, 5 } = delete $user{ $_ } for keys %user; | 
| 331 | 1 | 50 |  |  |  | 7 | if ( $user{private} == 2 ) { | 
|  |  | 50 |  |  |  |  |  | 
| 332 | 0 |  |  |  |  | 0 | $user{private} = 1 | 
| 333 |  |  |  |  |  |  | } | 
| 334 |  |  |  |  |  |  | elsif ( $user{private} == 1 ) { | 
| 335 | 0 |  |  |  |  | 0 | $user{unlisted} = 1; | 
| 336 |  |  |  |  |  |  | } | 
| 337 |  |  |  |  |  |  | else { | 
| 338 | 1 |  |  |  |  | 3 | delete $user{private}; | 
| 339 |  |  |  |  |  |  | } | 
| 340 |  |  |  |  |  |  |  | 
| 341 | 1 | 50 |  |  |  | 15 | return wantarray ? %user : \%user; | 
| 342 |  |  |  |  |  |  | } | 
| 343 |  |  |  |  |  |  |  | 
| 344 |  |  |  |  |  |  | sub _parse_xml { | 
| 345 | 1 |  |  | 1 |  | 33 | my ( $self, $content ) = @_; | 
| 346 |  |  |  |  |  |  |  | 
| 347 | 1 |  |  |  |  | 2 | my @out; | 
| 348 | 1 |  |  |  |  | 49 | for ( $content =~ m{(.+?)}gs ) { | 
| 349 | 18 |  |  |  |  | 232 | my %paste = ( m{<([^>]+)>(.*?)\1>}sg ); | 
| 350 | 18 |  |  |  |  | 143 | $paste{ substr $_, 6 } = delete $paste{ $_ } for keys %paste; | 
| 351 |  |  |  |  |  |  |  | 
| 352 | 18 |  |  |  |  | 26 | my $private_flag = delete $paste{private}; | 
| 353 | 18 | 50 |  |  |  | 34 | if ( $private_flag == 2 ) { $paste{private} = 1; } | 
|  | 0 | 50 |  |  |  | 0 |  | 
| 354 | 0 |  |  |  |  | 0 | elsif ( $private_flag == 1 ) { $paste{unlisted} = 1; } | 
| 355 |  |  |  |  |  |  |  | 
| 356 | 18 |  |  |  |  | 24 | push @out, \%paste; | 
| 357 |  |  |  |  |  |  | } | 
| 358 |  |  |  |  |  |  |  | 
| 359 | 1 | 50 |  |  |  | 16 | return wantarray ? @out : \@out; | 
| 360 |  |  |  |  |  |  | } | 
| 361 |  |  |  |  |  |  |  | 
| 362 |  |  |  |  |  |  | sub _get_user_key { | 
| 363 | 1 |  |  | 1 |  | 2 | my $self = shift; | 
| 364 |  |  |  |  |  |  |  | 
| 365 | 1 |  | 50 |  |  | 3 | return $self->user_key | 
| 366 |  |  |  |  |  |  | || return $self->_set_error('API user key must be provided' | 
| 367 |  |  |  |  |  |  | . ' to create private pastes. See ->user_key() or' | 
| 368 |  |  |  |  |  |  | . ' ->get_user_key() in the documentation.'); | 
| 369 |  |  |  |  |  |  | } | 
| 370 |  |  |  |  |  |  |  | 
| 371 |  |  |  |  |  |  | sub _get_api_key { | 
| 372 | 4 |  |  | 4 |  | 6 | my $self = shift; | 
| 373 |  |  |  |  |  |  |  | 
| 374 | 4 |  | 50 |  |  | 15 | return $self->api_key | 
| 375 |  |  |  |  |  |  | || return $self->_set_error(q|Can't operate without an API key.| | 
| 376 |  |  |  |  |  |  | . q| Sign up / Log in to pastebin.com, then go| | 
| 377 |  |  |  |  |  |  | . q| to http://pastebin.com/api to see your API key| | 
| 378 |  |  |  |  |  |  | . q| (it's in the section "Your Unique Developer API Key")|); | 
| 379 |  |  |  |  |  |  | } | 
| 380 |  |  |  |  |  |  |  | 
| 381 |  |  |  |  |  |  | sub _prepare_optional_api_options { | 
| 382 | 1 |  |  | 1 |  | 2 | my ( $self, $args ) = @_; | 
| 383 | 1 |  |  |  |  | 1 | my @out_args; | 
| 384 |  |  |  |  |  |  |  | 
| 385 |  |  |  |  |  |  | push @out_args, api_paste_name => $args->{title} | 
| 386 | 1 | 50 |  |  |  | 4 | if defined $args->{title}; # title of the paste | 
| 387 |  |  |  |  |  |  |  | 
| 388 | 1 | 50 |  |  |  | 3 | if ( defined $args->{format} ) { | 
| 389 |  |  |  |  |  |  | $self->_is_valid_format( $args->{format} ) | 
| 390 | 1 | 50 |  |  |  | 4 | or return $self->_set_error( | 
| 391 |  |  |  |  |  |  | 'Invalid syntax highlighting code. See ->valid_formats()' | 
| 392 |  |  |  |  |  |  | . ' method in the documentation' | 
| 393 |  |  |  |  |  |  | ); | 
| 394 | 1 |  |  |  |  | 3 | push @out_args, api_paste_format => $args->{format}; | 
| 395 |  |  |  |  |  |  | } | 
| 396 |  |  |  |  |  |  |  | 
| 397 | 1 | 50 | 33 |  |  | 4 | if( $args->{owned} and not $args->{private} ) { | 
| 398 | 0 | 0 | 0 |  |  | 0 | defined ( $args->{user_key} || $self->user_key ) | 
| 399 |  |  |  |  |  |  | or return $self->set_error( | 
| 400 |  |  |  |  |  |  | 'API user key must be provided to create owned pastes.' | 
| 401 |  |  |  |  |  |  | . ' See ->user_key() or ->get_user_key() in the' | 
| 402 |  |  |  |  |  |  | . ' documentation.' | 
| 403 |  |  |  |  |  |  | ); | 
| 404 |  |  |  |  |  |  |  | 
| 405 |  |  |  |  |  |  | push @out_args, | 
| 406 | 0 |  | 0 |  |  | 0 | api_user_key => ( $args->{user_key} || $self->user_key ); | 
| 407 |  |  |  |  |  |  | } | 
| 408 |  |  |  |  |  |  |  | 
| 409 | 1 | 50 |  |  |  | 3 | if ( $args->{private} ) { | 
|  |  | 0 |  |  |  |  |  | 
| 410 | 1 | 50 | 33 |  |  | 5 | defined ( $args->{user_key} || $self->user_key ) | 
| 411 |  |  |  |  |  |  | or return $self->_set_error( | 
| 412 |  |  |  |  |  |  | 'API user key must be provided to create private pastes.' | 
| 413 |  |  |  |  |  |  | . ' See ->user_key() or ->get_user_key() in the' | 
| 414 |  |  |  |  |  |  | . ' documentation.' | 
| 415 |  |  |  |  |  |  | ); | 
| 416 |  |  |  |  |  |  |  | 
| 417 |  |  |  |  |  |  | push @out_args, | 
| 418 |  |  |  |  |  |  | api_paste_private => 2, | 
| 419 | 1 |  | 33 |  |  | 14 | api_user_key => ( $args->{user_key} || $self->user_key ); | 
| 420 |  |  |  |  |  |  | } | 
| 421 |  |  |  |  |  |  | elsif ( $args->{unlisted} ) { | 
| 422 | 0 |  |  |  |  | 0 | push @out_args, api_paste_private => 1; | 
| 423 |  |  |  |  |  |  | } | 
| 424 |  |  |  |  |  |  | else { | 
| 425 |  |  |  |  |  |  | ### DEBUGGING NOTE: | 
| 426 |  |  |  |  |  |  | ### Pastebin will automatically list duplicate content | 
| 427 |  |  |  |  |  |  | ### or content with "some" keywords as unlisted | 
| 428 |  |  |  |  |  |  | ### even if we tell it to go public | 
| 429 | 0 |  |  |  |  | 0 | push @out_args, api_paste_private => 0; | 
| 430 |  |  |  |  |  |  | } | 
| 431 |  |  |  |  |  |  |  | 
| 432 | 1 | 50 |  |  |  | 11 | if ( $args->{expiry} ) { | 
| 433 |  |  |  |  |  |  | my $expiry = $self->_translate_expiry( $args->{expiry} ) | 
| 434 | 1 | 50 |  |  |  | 4 | or return $self->_set_error('Invalid `expiry` argument'); | 
| 435 |  |  |  |  |  |  |  | 
| 436 | 1 |  |  |  |  | 3 | push @out_args, api_paste_expire_date => $expiry; | 
| 437 |  |  |  |  |  |  | } | 
| 438 |  |  |  |  |  |  |  | 
| 439 | 1 |  |  |  |  | 6 | return @out_args; | 
| 440 |  |  |  |  |  |  | } | 
| 441 |  |  |  |  |  |  |  | 
| 442 |  |  |  |  |  |  | sub _translate_expiry { | 
| 443 | 1 |  |  | 1 |  | 1 | my ( $self, $expiry ) = @_; | 
| 444 |  |  |  |  |  |  |  | 
| 445 | 1 |  |  |  |  | 14 | my %expiries = ( | 
| 446 |  |  |  |  |  |  | # 10 Minutes | 
| 447 |  |  |  |  |  |  | '10m'   => '10M', | 
| 448 |  |  |  |  |  |  | m10     => '10M', | 
| 449 |  |  |  |  |  |  | asap    => '10M', | 
| 450 |  |  |  |  |  |  |  | 
| 451 |  |  |  |  |  |  | # 1 Hour | 
| 452 |  |  |  |  |  |  | h       => '1H', | 
| 453 |  |  |  |  |  |  | '1h'    => '1H', | 
| 454 |  |  |  |  |  |  |  | 
| 455 |  |  |  |  |  |  | # 1 Day | 
| 456 |  |  |  |  |  |  | d       => '1D', | 
| 457 |  |  |  |  |  |  | '1d'    => '1D', | 
| 458 |  |  |  |  |  |  | soon    => '1D', | 
| 459 |  |  |  |  |  |  |  | 
| 460 |  |  |  |  |  |  | # 1 Week | 
| 461 |  |  |  |  |  |  | w       => '1W', | 
| 462 |  |  |  |  |  |  | '1w'    => '1W', | 
| 463 |  |  |  |  |  |  | awhile  => '1W', | 
| 464 |  |  |  |  |  |  |  | 
| 465 |  |  |  |  |  |  | '2w'    => '2W', | 
| 466 |  |  |  |  |  |  | w2      => '2W', | 
| 467 |  |  |  |  |  |  |  | 
| 468 |  |  |  |  |  |  | # 1 Month | 
| 469 |  |  |  |  |  |  | '1m'    => '1M', | 
| 470 |  |  |  |  |  |  | m1      => '1M', | 
| 471 |  |  |  |  |  |  | eventually      => '1M', | 
| 472 |  |  |  |  |  |  |  | 
| 473 |  |  |  |  |  |  | # Never | 
| 474 |  |  |  |  |  |  | n       => 'N', | 
| 475 |  |  |  |  |  |  | never   => 'N', | 
| 476 |  |  |  |  |  |  | ); | 
| 477 |  |  |  |  |  |  |  | 
| 478 | 1 |  | 33 |  |  | 15 | return $expiries{ lc $expiry } | 
| 479 |  |  |  |  |  |  | || $self->_set_error('Invalid expiry value'); | 
| 480 |  |  |  |  |  |  | } | 
| 481 |  |  |  |  |  |  |  | 
| 482 |  |  |  |  |  |  | sub _set_error { | 
| 483 | 1 |  |  | 1 |  | 18 | my ( $self, $error ) = @_; | 
| 484 | 1 |  |  |  |  | 5 | $self->error( $error ); | 
| 485 | 1 |  |  |  |  | 28 | return; | 
| 486 |  |  |  |  |  |  | } | 
| 487 |  |  |  |  |  |  |  | 
| 488 |  |  |  |  |  |  | sub _is_valid_format { | 
| 489 | 1 |  |  | 1 |  | 2 | my ( $self, $format ) = @_; | 
| 490 |  |  |  |  |  |  |  | 
| 491 | 1 |  |  |  |  | 135 | my %formats = ( | 
| 492 |  |  |  |  |  |  | '4cs' => '4CS', | 
| 493 |  |  |  |  |  |  | '6502acme' => '6502 ACME Cross Assembler', | 
| 494 |  |  |  |  |  |  | '6502kickass' => '6502 Kick Assembler', | 
| 495 |  |  |  |  |  |  | '6502tasm' => '6502 TASM/64TASS', | 
| 496 |  |  |  |  |  |  | 'abap' => 'ABAP', | 
| 497 |  |  |  |  |  |  | 'actionscript' => 'ActionScript', | 
| 498 |  |  |  |  |  |  | 'actionscript3' => 'ActionScript 3', | 
| 499 |  |  |  |  |  |  | 'ada' => 'Ada', | 
| 500 |  |  |  |  |  |  | 'algol68' => 'ALGOL 68', | 
| 501 |  |  |  |  |  |  | 'apache' => 'Apache Log', | 
| 502 |  |  |  |  |  |  | 'applescript' => 'AppleScript', | 
| 503 |  |  |  |  |  |  | 'apt_sources' => 'APT Sources', | 
| 504 |  |  |  |  |  |  | 'arm' => 'ARM', | 
| 505 |  |  |  |  |  |  | 'asm' => 'ASM (NASM)', | 
| 506 |  |  |  |  |  |  | 'asp' => 'ASP', | 
| 507 |  |  |  |  |  |  | 'asymptote' => 'Asymptote', | 
| 508 |  |  |  |  |  |  | 'autoconf' => 'autoconf', | 
| 509 |  |  |  |  |  |  | 'autohotkey' => 'Autohotkey', | 
| 510 |  |  |  |  |  |  | 'autoit' => 'AutoIt', | 
| 511 |  |  |  |  |  |  | 'avisynth' => 'Avisynth', | 
| 512 |  |  |  |  |  |  | 'awk' => 'Awk', | 
| 513 |  |  |  |  |  |  | 'bascomavr' => 'BASCOM AVR', | 
| 514 |  |  |  |  |  |  | 'bash' => 'Bash', | 
| 515 |  |  |  |  |  |  | 'basic4gl' => 'Basic4GL', | 
| 516 |  |  |  |  |  |  | 'bibtex' => 'BibTeX', | 
| 517 |  |  |  |  |  |  | 'blitzbasic' => 'Blitz Basic', | 
| 518 |  |  |  |  |  |  | 'bnf' => 'BNF', | 
| 519 |  |  |  |  |  |  | 'boo' => 'BOO', | 
| 520 |  |  |  |  |  |  | 'bf' => 'BrainFuck', | 
| 521 |  |  |  |  |  |  | 'c' => 'C', | 
| 522 |  |  |  |  |  |  | 'c_mac' => 'C for Macs', | 
| 523 |  |  |  |  |  |  | 'cil' => 'C Intermediate Language', | 
| 524 |  |  |  |  |  |  | 'csharp' => 'C#', | 
| 525 |  |  |  |  |  |  | 'cpp' => 'C++', | 
| 526 |  |  |  |  |  |  | 'cpp-qt' => 'C++ (with QT extensions)', | 
| 527 |  |  |  |  |  |  | 'c_loadrunner' => 'C: Loadrunner', | 
| 528 |  |  |  |  |  |  | 'caddcl' => 'CAD DCL', | 
| 529 |  |  |  |  |  |  | 'cadlisp' => 'CAD Lisp', | 
| 530 |  |  |  |  |  |  | 'cfdg' => 'CFDG', | 
| 531 |  |  |  |  |  |  | 'chaiscript' => 'ChaiScript', | 
| 532 |  |  |  |  |  |  | 'clojure' => 'Clojure', | 
| 533 |  |  |  |  |  |  | 'klonec' => 'Clone C', | 
| 534 |  |  |  |  |  |  | 'klonecpp' => 'Clone C++', | 
| 535 |  |  |  |  |  |  | 'cmake' => 'CMake', | 
| 536 |  |  |  |  |  |  | 'cobol' => 'COBOL', | 
| 537 |  |  |  |  |  |  | 'coffeescript' => 'CoffeeScript', | 
| 538 |  |  |  |  |  |  | 'cfm' => 'ColdFusion', | 
| 539 |  |  |  |  |  |  | 'css' => 'CSS', | 
| 540 |  |  |  |  |  |  | 'cuesheet' => 'Cuesheet', | 
| 541 |  |  |  |  |  |  | 'd' => 'D', | 
| 542 |  |  |  |  |  |  | 'dcl' => 'DCL', | 
| 543 |  |  |  |  |  |  | 'dcpu16' => 'DCPU-16', | 
| 544 |  |  |  |  |  |  | 'dcs' => 'DCS', | 
| 545 |  |  |  |  |  |  | 'delphi' => 'Delphi', | 
| 546 |  |  |  |  |  |  | 'oxygene' => 'Delphi Prism (Oxygene)', | 
| 547 |  |  |  |  |  |  | 'diff' => 'Diff', | 
| 548 |  |  |  |  |  |  | 'div' => 'DIV', | 
| 549 |  |  |  |  |  |  | 'dos' => 'DOS', | 
| 550 |  |  |  |  |  |  | 'dot' => 'DOT', | 
| 551 |  |  |  |  |  |  | 'e' => 'E', | 
| 552 |  |  |  |  |  |  | 'ecmascript' => 'ECMAScript', | 
| 553 |  |  |  |  |  |  | 'eiffel' => 'Eiffel', | 
| 554 |  |  |  |  |  |  | 'email' => 'Email', | 
| 555 |  |  |  |  |  |  | 'epc' => 'EPC', | 
| 556 |  |  |  |  |  |  | 'erlang' => 'Erlang', | 
| 557 |  |  |  |  |  |  | 'fsharp' => 'F#', | 
| 558 |  |  |  |  |  |  | 'falcon' => 'Falcon', | 
| 559 |  |  |  |  |  |  | 'fo' => 'FO Language', | 
| 560 |  |  |  |  |  |  | 'f1' => 'Formula One', | 
| 561 |  |  |  |  |  |  | 'fortran' => 'Fortran', | 
| 562 |  |  |  |  |  |  | 'freebasic' => 'FreeBasic', | 
| 563 |  |  |  |  |  |  | 'freeswitch' => 'FreeSWITCH', | 
| 564 |  |  |  |  |  |  | 'gambas' => 'GAMBAS', | 
| 565 |  |  |  |  |  |  | 'gml' => 'Game Maker', | 
| 566 |  |  |  |  |  |  | 'gdb' => 'GDB', | 
| 567 |  |  |  |  |  |  | 'genero' => 'Genero', | 
| 568 |  |  |  |  |  |  | 'genie' => 'Genie', | 
| 569 |  |  |  |  |  |  | 'gettext' => 'GetText', | 
| 570 |  |  |  |  |  |  | 'go' => 'Go', | 
| 571 |  |  |  |  |  |  | 'groovy' => 'Groovy', | 
| 572 |  |  |  |  |  |  | 'gwbasic' => 'GwBasic', | 
| 573 |  |  |  |  |  |  | 'haskell' => 'Haskell', | 
| 574 |  |  |  |  |  |  | 'haxe' => 'Haxe', | 
| 575 |  |  |  |  |  |  | 'hicest' => 'HicEst', | 
| 576 |  |  |  |  |  |  | 'hq9plus' => 'HQ9 Plus', | 
| 577 |  |  |  |  |  |  | 'html4strict' => 'HTML', | 
| 578 |  |  |  |  |  |  | 'html5' => 'HTML 5', | 
| 579 |  |  |  |  |  |  | 'icon' => 'Icon', | 
| 580 |  |  |  |  |  |  | 'idl' => 'IDL', | 
| 581 |  |  |  |  |  |  | 'ini' => 'INI file', | 
| 582 |  |  |  |  |  |  | 'inno' => 'Inno Script', | 
| 583 |  |  |  |  |  |  | 'intercal' => 'INTERCAL', | 
| 584 |  |  |  |  |  |  | 'io' => 'IO', | 
| 585 |  |  |  |  |  |  | 'j' => 'J', | 
| 586 |  |  |  |  |  |  | 'java' => 'Java', | 
| 587 |  |  |  |  |  |  | 'java5' => 'Java 5', | 
| 588 |  |  |  |  |  |  | 'javascript' => 'JavaScript', | 
| 589 |  |  |  |  |  |  | 'jquery' => 'jQuery', | 
| 590 |  |  |  |  |  |  | 'kixtart' => 'KiXtart', | 
| 591 |  |  |  |  |  |  | 'latex' => 'Latex', | 
| 592 |  |  |  |  |  |  | 'ldif' => 'LDIF', | 
| 593 |  |  |  |  |  |  | 'lb' => 'Liberty BASIC', | 
| 594 |  |  |  |  |  |  | 'lsl2' => 'Linden Scripting', | 
| 595 |  |  |  |  |  |  | 'lisp' => 'Lisp', | 
| 596 |  |  |  |  |  |  | 'llvm' => 'LLVM', | 
| 597 |  |  |  |  |  |  | 'locobasic' => 'Loco Basic', | 
| 598 |  |  |  |  |  |  | 'logtalk' => 'Logtalk', | 
| 599 |  |  |  |  |  |  | 'lolcode' => 'LOL Code', | 
| 600 |  |  |  |  |  |  | 'lotusformulas' => 'Lotus Formulas', | 
| 601 |  |  |  |  |  |  | 'lotusscript' => 'Lotus Script', | 
| 602 |  |  |  |  |  |  | 'lscript' => 'LScript', | 
| 603 |  |  |  |  |  |  | 'lua' => 'Lua', | 
| 604 |  |  |  |  |  |  | 'm68k' => 'M68000 Assembler', | 
| 605 |  |  |  |  |  |  | 'magiksf' => 'MagikSF', | 
| 606 |  |  |  |  |  |  | 'make' => 'Make', | 
| 607 |  |  |  |  |  |  | 'mapbasic' => 'MapBasic', | 
| 608 |  |  |  |  |  |  | 'matlab' => 'MatLab', | 
| 609 |  |  |  |  |  |  | 'mirc' => 'mIRC', | 
| 610 |  |  |  |  |  |  | 'mmix' => 'MIX Assembler', | 
| 611 |  |  |  |  |  |  | 'modula2' => 'Modula 2', | 
| 612 |  |  |  |  |  |  | 'modula3' => 'Modula 3', | 
| 613 |  |  |  |  |  |  | '68000devpac' => 'Motorola 68000 HiSoft Dev', | 
| 614 |  |  |  |  |  |  | 'mpasm' => 'MPASM', | 
| 615 |  |  |  |  |  |  | 'mxml' => 'MXML', | 
| 616 |  |  |  |  |  |  | 'mysql' => 'MySQL', | 
| 617 |  |  |  |  |  |  | 'nagios' => 'Nagios', | 
| 618 |  |  |  |  |  |  | 'newlisp' => 'newLISP', | 
| 619 |  |  |  |  |  |  | 'text' => 'None', | 
| 620 |  |  |  |  |  |  | 'nsis' => 'NullSoft Installer', | 
| 621 |  |  |  |  |  |  | 'oberon2' => 'Oberon 2', | 
| 622 |  |  |  |  |  |  | 'objeck' => 'Objeck Programming Langua', | 
| 623 |  |  |  |  |  |  | 'objc' => 'Objective C', | 
| 624 |  |  |  |  |  |  | 'ocaml-brief' => 'OCalm Brief', | 
| 625 |  |  |  |  |  |  | 'ocaml' => 'OCaml', | 
| 626 |  |  |  |  |  |  | 'octave' => 'Octave', | 
| 627 |  |  |  |  |  |  | 'pf' => 'OpenBSD PACKET FILTER', | 
| 628 |  |  |  |  |  |  | 'glsl' => 'OpenGL Shading', | 
| 629 |  |  |  |  |  |  | 'oobas' => 'Openoffice BASIC', | 
| 630 |  |  |  |  |  |  | 'oracle11' => 'Oracle 11', | 
| 631 |  |  |  |  |  |  | 'oracle8' => 'Oracle 8', | 
| 632 |  |  |  |  |  |  | 'oz' => 'Oz', | 
| 633 |  |  |  |  |  |  | 'parasail' => 'ParaSail', | 
| 634 |  |  |  |  |  |  | 'parigp' => 'PARI/GP', | 
| 635 |  |  |  |  |  |  | 'pascal' => 'Pascal', | 
| 636 |  |  |  |  |  |  | 'pawn' => 'PAWN', | 
| 637 |  |  |  |  |  |  | 'pcre' => 'PCRE', | 
| 638 |  |  |  |  |  |  | 'per' => 'Per', | 
| 639 |  |  |  |  |  |  | 'perl' => 'Perl', | 
| 640 |  |  |  |  |  |  | 'perl6' => 'Perl 6', | 
| 641 |  |  |  |  |  |  | 'php' => 'PHP', | 
| 642 |  |  |  |  |  |  | 'php-brief' => 'PHP Brief', | 
| 643 |  |  |  |  |  |  | 'pic16' => 'Pic 16', | 
| 644 |  |  |  |  |  |  | 'pike' => 'Pike', | 
| 645 |  |  |  |  |  |  | 'pixelbender' => 'Pixel Bender', | 
| 646 |  |  |  |  |  |  | 'plsql' => 'PL/SQL', | 
| 647 |  |  |  |  |  |  | 'postgresql' => 'PostgreSQL', | 
| 648 |  |  |  |  |  |  | 'povray' => 'POV-Ray', | 
| 649 |  |  |  |  |  |  | 'powershell' => 'Power Shell', | 
| 650 |  |  |  |  |  |  | 'powerbuilder' => 'PowerBuilder', | 
| 651 |  |  |  |  |  |  | 'proftpd' => 'ProFTPd', | 
| 652 |  |  |  |  |  |  | 'progress' => 'Progress', | 
| 653 |  |  |  |  |  |  | 'prolog' => 'Prolog', | 
| 654 |  |  |  |  |  |  | 'properties' => 'Properties', | 
| 655 |  |  |  |  |  |  | 'providex' => 'ProvideX', | 
| 656 |  |  |  |  |  |  | 'purebasic' => 'PureBasic', | 
| 657 |  |  |  |  |  |  | 'pycon' => 'PyCon', | 
| 658 |  |  |  |  |  |  | 'python' => 'Python', | 
| 659 |  |  |  |  |  |  | 'pys60' => 'Python for S60', | 
| 660 |  |  |  |  |  |  | 'q' => 'q/kdb+', | 
| 661 |  |  |  |  |  |  | 'qbasic' => 'QBasic', | 
| 662 |  |  |  |  |  |  | 'rsplus' => 'R', | 
| 663 |  |  |  |  |  |  | 'rails' => 'Rails', | 
| 664 |  |  |  |  |  |  | 'rebol' => 'REBOL', | 
| 665 |  |  |  |  |  |  | 'reg' => 'REG', | 
| 666 |  |  |  |  |  |  | 'rexx' => 'Rexx', | 
| 667 |  |  |  |  |  |  | 'robots' => 'Robots', | 
| 668 |  |  |  |  |  |  | 'rpmspec' => 'RPM Spec', | 
| 669 |  |  |  |  |  |  | 'ruby' => 'Ruby', | 
| 670 |  |  |  |  |  |  | 'gnuplot' => 'Ruby Gnuplot', | 
| 671 |  |  |  |  |  |  | 'sas' => 'SAS', | 
| 672 |  |  |  |  |  |  | 'scala' => 'Scala', | 
| 673 |  |  |  |  |  |  | 'scheme' => 'Scheme', | 
| 674 |  |  |  |  |  |  | 'scilab' => 'Scilab', | 
| 675 |  |  |  |  |  |  | 'sdlbasic' => 'SdlBasic', | 
| 676 |  |  |  |  |  |  | 'smalltalk' => 'Smalltalk', | 
| 677 |  |  |  |  |  |  | 'smarty' => 'Smarty', | 
| 678 |  |  |  |  |  |  | 'spark' => 'SPARK', | 
| 679 |  |  |  |  |  |  | 'sparql' => 'SPARQL', | 
| 680 |  |  |  |  |  |  | 'sql' => 'SQL', | 
| 681 |  |  |  |  |  |  | 'stonescript' => 'StoneScript', | 
| 682 |  |  |  |  |  |  | 'systemverilog' => 'SystemVerilog', | 
| 683 |  |  |  |  |  |  | 'tsql' => 'T-SQL', | 
| 684 |  |  |  |  |  |  | 'tcl' => 'TCL', | 
| 685 |  |  |  |  |  |  | 'teraterm' => 'Tera Term', | 
| 686 |  |  |  |  |  |  | 'thinbasic' => 'thinBasic', | 
| 687 |  |  |  |  |  |  | 'typoscript' => 'TypoScript', | 
| 688 |  |  |  |  |  |  | 'unicon' => 'Unicon', | 
| 689 |  |  |  |  |  |  | 'uscript' => 'UnrealScript', | 
| 690 |  |  |  |  |  |  | 'ups' => 'UPC', | 
| 691 |  |  |  |  |  |  | 'urbi' => 'Urbi', | 
| 692 |  |  |  |  |  |  | 'vala' => 'Vala', | 
| 693 |  |  |  |  |  |  | 'vbnet' => 'VB.NET', | 
| 694 |  |  |  |  |  |  | 'vedit' => 'Vedit', | 
| 695 |  |  |  |  |  |  | 'verilog' => 'VeriLog', | 
| 696 |  |  |  |  |  |  | 'vhdl' => 'VHDL', | 
| 697 |  |  |  |  |  |  | 'vim' => 'VIM', | 
| 698 |  |  |  |  |  |  | 'visualprolog' => 'Visual Pro Log', | 
| 699 |  |  |  |  |  |  | 'vb' => 'VisualBasic', | 
| 700 |  |  |  |  |  |  | 'visualfoxpro' => 'VisualFoxPro', | 
| 701 |  |  |  |  |  |  | 'whitespace' => 'WhiteSpace', | 
| 702 |  |  |  |  |  |  | 'whois' => 'WHOIS', | 
| 703 |  |  |  |  |  |  | 'winbatch' => 'Winbatch', | 
| 704 |  |  |  |  |  |  | 'xbasic' => 'XBasic', | 
| 705 |  |  |  |  |  |  | 'xml' => 'XML', | 
| 706 |  |  |  |  |  |  | 'xorg_conf' => 'Xorg Config', | 
| 707 |  |  |  |  |  |  | 'xpp' => 'XPP', | 
| 708 |  |  |  |  |  |  | 'yaml' => 'YAML', | 
| 709 |  |  |  |  |  |  | 'z80' => 'Z80 Assembler', | 
| 710 |  |  |  |  |  |  | 'zxbasic' => 'ZXBasic', | 
| 711 |  |  |  |  |  |  | ); | 
| 712 |  |  |  |  |  |  |  | 
| 713 | 1 |  | 33 |  |  | 19 | return $formats{ $format } | 
| 714 |  |  |  |  |  |  | || $self->_set_error('Invalid syntax highlighting code'); | 
| 715 |  |  |  |  |  |  | } | 
| 716 |  |  |  |  |  |  |  | 
| 717 |  |  |  |  |  |  | 1; | 
| 718 |  |  |  |  |  |  |  | 
| 719 |  |  |  |  |  |  | __END__ |