line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Mechanize::Plugin::HelloWorld; |
2
|
11
|
|
|
11
|
|
11141
|
use strict; |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
382
|
|
3
|
11
|
|
|
11
|
|
72
|
use warnings; |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
1386
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
WWW::Mechanize::Plugin::HelloWorld - a sample WWW::Mechanize::Pluggable plugin |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
-head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use WWW::Mechanize::Pluggable; |
12
|
|
|
|
|
|
|
# This module is automatically loaded into WWW::Mechanize::Pluggable |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This module shows how to mess with the C object contained |
17
|
|
|
|
|
|
|
within the C object. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Further refinements are left to the reader. Note that the fields in the |
20
|
|
|
|
|
|
|
C object are also available to the plugins. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 USAGE |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $mech = new WWW::Mechanize::Pluggable; |
25
|
|
|
|
|
|
|
$mech->hello_world; |
26
|
|
|
|
|
|
|
# $mech->content now eq 'hello world' |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 BUGS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
None known. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 SUPPORT |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Contact the author at C. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 AUTHOR |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Joe McMahon |
39
|
|
|
|
|
|
|
mcmahon@yahoo-inc.com |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 COPYRIGHT |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Copyright 2005 by Joe McMahon and Yahoo! |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This program is free software; you can redistribute |
46
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
The full text of the license can be found in the |
49
|
|
|
|
|
|
|
LICENSE file included with this module. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SEE ALSO |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
L, C |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 CLASS METHODS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 import |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This function snags any 'helloworld' key-value pair off the |
60
|
|
|
|
|
|
|
C |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Currently this uses a global variable in the C |
63
|
|
|
|
|
|
|
namespace to capture the value. This is icky and should be replaced |
64
|
|
|
|
|
|
|
with something more elegant. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub import { |
69
|
11
|
|
|
11
|
|
28
|
my ($class, %args) = @_; |
70
|
11
|
50
|
|
|
|
5377
|
if (defined $args{'helloworld'}) { |
71
|
0
|
|
|
|
|
0
|
$WWW::Mechanize::Pluggable::HelloWorld = $args{'helloworld'}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 init |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
The C function exports C into the caller's namespace. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub init { |
82
|
11
|
|
|
11
|
|
56
|
no strict 'refs'; |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
1435
|
|
83
|
12
|
|
|
12
|
1
|
37
|
*{caller() . '::hello_world'} = \&hello_world; |
|
12
|
|
|
|
|
426
|
|
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 hello_world |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Just a demonstration function; replaces the current content with 'hello world'. |
89
|
|
|
|
|
|
|
It should be noted that this is not going to pass most tests for "successfully |
90
|
|
|
|
|
|
|
fetched page" because C hasn't processed a valid |
91
|
|
|
|
|
|
|
request-response pair. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub hello_world { |
96
|
0
|
|
|
0
|
1
|
|
my ($self) = shift; |
97
|
0
|
|
|
|
|
|
$self->{Mech}->{content} = 'hello world'; |
98
|
0
|
|
|
|
|
|
$self->{HELLO} = $WWW::Mechanize::Pluggable::HelloWorld; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |