| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
766
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
263
|
|
|
2
|
|
|
|
|
|
|
package IO::Automatic; |
|
3
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub new { |
|
6
|
1
|
|
|
1
|
0
|
553
|
my $class = shift; |
|
7
|
1
|
|
|
|
|
14
|
my ($dest) = @_; # preserve @_ but extract $dest to examine it |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
50
|
|
|
|
6
|
if (ref $dest eq 'SCALAR') { |
|
10
|
1
|
|
|
|
|
1172
|
require IO::Scalar; |
|
11
|
1
|
|
|
|
|
15710
|
return IO::Scalar->new( @_ ); |
|
12
|
|
|
|
|
|
|
} |
|
13
|
0
|
0
|
|
|
|
|
return $dest if ref $dest eq 'GLOB'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
$! = "Don't know what to do with something of type ". ref $dest; |
|
16
|
0
|
0
|
|
|
|
|
return if ref $dest; |
|
17
|
|
|
|
|
|
|
|
|
18
|
0
|
0
|
|
|
|
|
if ( $dest =~ /\.(?:gz|Z)$/ ) { |
|
19
|
0
|
|
|
|
|
|
require IO::Zlib; |
|
20
|
0
|
|
|
|
|
|
return IO::Zlib->new( @_ ); |
|
21
|
|
|
|
|
|
|
} |
|
22
|
0
|
|
|
|
|
|
require IO::File; |
|
23
|
0
|
|
|
|
|
|
return IO::File->new( @_ ); |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 NAME |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
IO::Automatic - automatically choose a suitable IO::* module |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
use IO::Automatic; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# scalar |
|
37
|
|
|
|
|
|
|
my $scalar; |
|
38
|
|
|
|
|
|
|
my $io = IO::Automatic->new( \$scalar ); |
|
39
|
|
|
|
|
|
|
print $io "Hello World\n"; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
IO::Automatic provides a simple factory for creating new output |
|
44
|
|
|
|
|
|
|
handles. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Several types of automatic conversion are supplied. If no conversion |
|
47
|
|
|
|
|
|
|
can be done, we return false. Only the first argument is examined to |
|
48
|
|
|
|
|
|
|
determine, but all the arguments will be passed through so you can |
|
49
|
|
|
|
|
|
|
also supply file mode specifications. |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 Scalar references |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Scalar references are translated into IO::Scalar objects. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 Glob references |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Globs are returned untouched as it is assumed they will already be |
|
58
|
|
|
|
|
|
|
suitable for use as IO handles. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 Plain scalar |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
A plain scalar is assumed to be a filename and so is transformed into |
|
63
|
|
|
|
|
|
|
an IO::Zlib or IO::File object as appropriate. |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 AUTHOR |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Richard Clamp |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Copyright (C) 2003, 2005 Richard Clamp. All Rights Reserved. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it |
|
74
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
L, L, L |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
|
81
|
|
|
|
|
|
|
|