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