line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
264146
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
38
|
|
2
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
158
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package ARGV::URL; |
5
|
|
|
|
|
|
|
{ |
6
|
|
|
|
|
|
|
$ARGV::URL::VERSION = '0.93'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub import |
10
|
|
|
|
|
|
|
{ |
11
|
|
|
|
|
|
|
# Inspired from L |
12
|
1
|
50
|
|
1
|
|
5277
|
@ARGV = map { m#^[a-z]{2,}://# ? qq#lwp-request -m GET "$_" |# : $_ } @ARGV; |
|
1
|
|
|
|
|
6
|
|
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
1; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
ARGV::URL - Wrap URLs from @ARGV for fetching and content consumption with <> |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
From one-liners: |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
perl -MARGV::URL -E "... <> ... " $file_or_url ... |
26
|
|
|
|
|
|
|
perl -MARGV::URL -nE "..." $file_or_uri ... |
27
|
|
|
|
|
|
|
perl -MARGV::URL -pE "..." $file_or_url ... |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
From a script: |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use ARG::URL; |
32
|
|
|
|
|
|
|
... |
33
|
|
|
|
|
|
|
while (<>) { |
34
|
|
|
|
|
|
|
... |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
From a script that takes command-line options that should not be processed by |
37
|
|
|
|
|
|
|
C : |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Skipping import |
40
|
|
|
|
|
|
|
use ARGV::URL (); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
... extract options from @ARGV ... |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Prepare URLs: do import now |
45
|
|
|
|
|
|
|
ARGV::URL->import; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 DESCRIPTION |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
This module adds some power to the diamond (<>) operator (see L): |
50
|
|
|
|
|
|
|
importing the module will transform URLs in C<@ARGV> so that their content is |
51
|
|
|
|
|
|
|
fetched and fed to <> like what is done for filenames in the standard |
52
|
|
|
|
|
|
|
behavior. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 IMPLEMENTATION DETAILS |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
I implementation details are specific to this release and may change |
57
|
|
|
|
|
|
|
in a later release.> |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Have a look at the code: this is a 3-lines module. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Fetching URLs is done using the following command: |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
lwp-request -m GET "$url" |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SEE ALSO |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=over 4 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item * |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
About the diamond operator (C<<>>): L, L |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item * |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Some other modules that adds magic to C<@ARGV>: L, L |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=back |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 AUTHOR |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Olivier MenguE, L. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Copyright E 2011 Olivier MenguE. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
88
|
|
|
|
|
|
|
the same terms as Perl 5 itself. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|