| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Acme::URL; | 
| 2 | 1 |  |  | 1 |  | 26515 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 40 |  | 
| 3 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 28 |  | 
| 4 | 1 |  |  | 1 |  | 26 | use 5.008001; | 
|  | 1 |  |  |  |  | 5 |  | 
|  | 1 |  |  |  |  | 28 |  | 
| 5 | 1 |  |  | 1 |  | 2360 | use Devel::Declare (); | 
|  | 1 |  |  |  |  | 35282 |  | 
|  | 1 |  |  |  |  | 32 |  | 
| 6 | 1 |  |  | 1 |  | 1868 | use LWP::Simple (); | 
|  | 1 |  |  |  |  | 103880 |  | 
|  | 1 |  |  |  |  | 30 |  | 
| 7 | 1 |  |  | 1 |  | 11 | use base 'Devel::Declare::Context::Simple'; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 1031 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | our $VERSION = '0.01'; | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | sub import { | 
| 12 | 1 |  |  | 1 |  | 11 | my $class  = shift; | 
| 13 | 1 |  |  |  |  | 3 | my $caller = caller; | 
| 14 | 1 |  |  |  |  | 10 | my $ctx    = __PACKAGE__->new; | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | Devel::Declare->setup_for( | 
| 17 |  |  |  |  |  |  | $caller, | 
| 18 |  |  |  |  |  |  | { | 
| 19 |  |  |  |  |  |  | http => { | 
| 20 | 0 |  |  | 0 |  | 0 | const => sub { $ctx->parser(@_) }, | 
| 21 |  |  |  |  |  |  | }, | 
| 22 |  |  |  |  |  |  | }, | 
| 23 | 1 |  |  |  |  | 16 | ); | 
| 24 |  |  |  |  |  |  |  | 
| 25 | 1 |  |  | 1 |  | 19485 | no strict 'refs'; | 
|  | 1 |  |  |  |  | 4 |  | 
|  | 1 |  |  |  |  | 252 |  | 
| 26 | 1 |  |  | 0 |  | 31 | *{$caller.'::http'} = sub ($) { LWP::Simple::get( $_[0] ) }; | 
|  | 1 |  |  |  |  | 15 |  | 
|  | 0 |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | } | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | sub parser { | 
| 30 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 31 | 0 |  |  |  |  |  | $self->init(@_); | 
| 32 | 0 |  |  |  |  |  | $self->skip_declarator;          # skip past "http" | 
| 33 |  |  |  |  |  |  |  | 
| 34 | 0 |  |  |  |  |  | my $line = $self->get_linestr;   # get me current line of code | 
| 35 | 0 |  |  |  |  |  | my $pos  = $self->offset;        # position just after "http" | 
| 36 | 0 |  |  |  |  |  | my $url  = substr $line, $pos;   # url & everything after "http" | 
| 37 |  |  |  |  |  |  |  | 
| 38 | 0 |  |  |  |  |  | for my $c (split //, $url) { | 
| 39 |  |  |  |  |  |  | # if blank, semicolon, closing parenthesis or a comma(!) then no longer a URL | 
| 40 | 0 | 0 |  |  |  |  | last if $c eq q{ }; | 
| 41 | 0 | 0 |  |  |  |  | last if $c eq q{;}; | 
| 42 | 0 | 0 |  |  |  |  | last if $c eq q{)}; | 
| 43 | 0 | 0 |  |  |  |  | last if $c eq q{,}; | 
| 44 | 0 |  |  |  |  |  | $pos++; | 
| 45 |  |  |  |  |  |  | } | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | # wrap the url with http() sub and quotes | 
| 48 | 0 |  |  |  |  |  | substr( $line, $pos,          0 ) = q{")}; | 
| 49 | 0 |  |  |  |  |  | substr( $line, $self->offset, 0 ) = q{("http}; | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | # pass back changes to parser | 
| 52 | 0 |  |  |  |  |  | $self->set_linestr( $line ); | 
| 53 |  |  |  |  |  |  |  | 
| 54 | 0 |  |  |  |  |  | return; | 
| 55 |  |  |  |  |  |  | } | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | 1; | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | __END__ |