| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package WWW::Mechanize::Firefox::DSL; | 
| 2 | 1 |  |  | 1 |  | 66591 | use strict; | 
|  | 1 |  |  |  |  | 11 |  | 
|  | 1 |  |  |  |  | 29 |  | 
| 3 | 1 |  |  | 1 |  | 822 | use WWW::Mechanize::Firefox; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 40 |  | 
| 4 | 1 |  |  | 1 |  | 534 | use Object::Import; | 
|  | 1 |  |  |  |  | 25579 |  | 
|  | 1 |  |  |  |  | 7 |  | 
| 5 | 1 |  |  | 1 |  | 50 | use Carp qw(croak); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 217 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | our $VERSION = '0.80'; | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | our @CARP_NOT = (qw[ | 
| 10 |  |  |  |  |  |  | WWW::Mechanize::Firefox | 
| 11 |  |  |  |  |  |  | ]); | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | =head1 NAME | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | WWW::Mechanize::Firefox::DSL - Domain Specific Language for short scripts | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | use WWW::Mechanize::Firefox::DSL '$mech'; | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | get 'http://google.de'; | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | my @links = selector('a'); | 
| 24 |  |  |  |  |  |  | print $_->{innerHTML},"\n" for @links; | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | click($links[0]); | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | print content; | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | This module exports all methods of one WWW::Mechanize::Firefox | 
| 31 |  |  |  |  |  |  | object as subroutines. That way, you can write short scripts without | 
| 32 |  |  |  |  |  |  | cluttering every line with C<< $mech-> >>. | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | This module is highly experimental and might vanish from the distribution | 
| 35 |  |  |  |  |  |  | again if I find that it is useless. | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | =cut | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | sub import { | 
| 40 | 1 |  |  | 1 |  | 12 | my ($class, %options); | 
| 41 | 1 | 50 |  |  |  | 4 | if (@_ == 2) { | 
| 42 | 0 |  |  |  |  | 0 | ($class, $options{ name }) = @_; | 
| 43 |  |  |  |  |  |  | } else { | 
| 44 | 1 |  |  |  |  | 3 | ($class, %options) = @_; | 
| 45 |  |  |  |  |  |  | }; | 
| 46 | 1 |  | 33 |  |  | 8 | my $target = delete $options{ target } || caller; | 
| 47 | 1 |  | 50 |  |  | 6 | my $name = delete $options{ name } || '$mech'; | 
| 48 | 1 |  |  |  |  | 8 | my $mech = WWW::Mechanize::Firefox->new(%options); | 
| 49 |  |  |  |  |  |  |  | 
| 50 | 0 | 0 |  |  |  |  | $name =~ s/^[\$]// | 
| 51 |  |  |  |  |  |  | or croak 'Variable name must start with $'; | 
| 52 |  |  |  |  |  |  | { | 
| 53 | 1 |  |  | 1 |  | 8 | no strict 'refs'; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 106 |  | 
|  | 0 |  |  |  |  |  |  | 
| 54 | 0 |  |  |  |  |  | *{"$target\::$name"} = \$mech; | 
|  | 0 |  |  |  |  |  |  | 
| 55 | 0 |  |  |  |  |  | import Object::Import \${"$target\::$name"}, | 
|  | 0 |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | deref => 1, | 
| 57 |  |  |  |  |  |  | target => $target, | 
| 58 |  |  |  |  |  |  | ; | 
| 59 |  |  |  |  |  |  | }; | 
| 60 |  |  |  |  |  |  | }; | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | 1; | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | =head1 AUTHORS | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | Max Maischein C | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | =head1 COPYRIGHT (c) | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | Copyright 2009-2014 by Max Maischein C. | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | =head1 LICENSE | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | This module is released under the same terms as Perl itself. | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | =cut |