line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::ConvertPlatform; |
2
|
1
|
|
|
1
|
|
722
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
3
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
585
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$VERSION = '1.00'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
0
|
23298
|
my $proto = shift; |
10
|
1
|
|
33
|
|
|
15
|
my $class = ref($proto) || $proto; |
11
|
1
|
|
|
|
|
4
|
my $self = {}; |
12
|
1
|
|
|
|
|
5
|
$self->{FILENAME} = undef; |
13
|
1
|
|
|
|
|
3
|
$self->{OLDCONTENTS} = undef; |
14
|
1
|
|
|
|
|
2
|
$self->{NEWCONTENTS} = undef; |
15
|
1
|
|
|
|
|
3
|
$self->{CONVERTTO} = undef; |
16
|
1
|
|
|
|
|
3
|
bless ($self, $class); |
17
|
1
|
|
|
|
|
5
|
return $self; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub convert_to { |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
0
|
33
|
my $self = shift; |
24
|
1
|
50
|
|
|
|
5
|
if (@_) { $self->{CONVERTTO} = shift } |
|
1
|
|
|
|
|
3
|
|
25
|
1
|
|
|
|
|
5
|
return $self->{CONVERTTO}; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub filename { |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
1
|
0
|
84
|
my $self = shift; |
32
|
1
|
50
|
|
|
|
7
|
if (@_) { $self->{FILENAME} = shift } |
|
1
|
|
|
|
|
5
|
|
33
|
1
|
|
|
|
|
3
|
return $self->{FILENAME}; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub newcontents { |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
40
|
0
|
0
|
|
|
|
0
|
if (@_) { $self->{NEWCONTENTS} = shift } |
|
0
|
|
|
|
|
0
|
|
41
|
0
|
|
|
|
|
0
|
return $self->{NEWCONTENTS}; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub oldcontents { |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
48
|
0
|
0
|
|
|
|
0
|
if (@_) { $self->{OLDCONTENTS} = shift } |
|
0
|
|
|
|
|
0
|
|
49
|
0
|
|
|
|
|
0
|
return $self->{OLDCONTENTS}; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub process_file { |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
1
|
0
|
31
|
my $self = shift; |
57
|
1
|
|
|
|
|
3
|
my $mode = $self->{CONVERTTO}; |
58
|
1
|
|
|
|
|
3
|
my $file = $self->{FILENAME}; |
59
|
1
|
|
|
|
|
3
|
my $old = undef; |
60
|
1
|
|
|
|
|
2
|
my $results = undef; |
61
|
1
|
|
|
|
|
48
|
open (FILE, "$file"); |
62
|
1
|
|
|
|
|
54
|
while () { |
63
|
66
|
|
|
|
|
162
|
$old .= $_; |
64
|
|
|
|
|
|
|
# convert everything to unix first |
65
|
66
|
|
|
|
|
120
|
s/\015\012/\012/g; |
66
|
66
|
|
|
|
|
199
|
s/\015/\012/g; |
67
|
|
|
|
|
|
|
# if they want dos format |
68
|
66
|
50
|
|
|
|
148
|
s/\012/\015\012/g if ($mode eq "dos"); |
69
|
|
|
|
|
|
|
# if they want mac format |
70
|
66
|
50
|
|
|
|
310
|
s/\012/\015/g if ($mode eq "mac"); |
71
|
66
|
|
|
|
|
372
|
$results .= $_; |
72
|
|
|
|
|
|
|
} |
73
|
1
|
|
|
|
|
42
|
close (FILE); |
74
|
1
|
|
|
|
|
8
|
$self->{OLDCONTENTS} = $old; |
75
|
1
|
|
|
|
|
30
|
$self->{NEWCONTENTS} = $results; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub replace_file { |
80
|
|
|
|
|
|
|
|
81
|
1
|
|
|
1
|
0
|
46
|
my $self = shift; |
82
|
1
|
|
|
|
|
3
|
my $file = $self->{FILENAME}; |
83
|
1
|
|
|
|
|
108
|
open (NEWFILE, ">".$file); |
84
|
1
|
|
|
|
|
78
|
print NEWFILE $self->{NEWCONTENTS}; |
85
|
1
|
|
|
|
|
14
|
close (NEWFILE); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub backup_file { |
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
1
|
0
|
40
|
my $self = shift; |
93
|
1
|
|
|
|
|
5
|
my $file = $self->{FILENAME}; |
94
|
1
|
|
|
|
|
3
|
$file .= ".bak"; |
95
|
1
|
|
|
|
|
117
|
open (BAKFILE, ">$file"); |
96
|
1
|
|
|
|
|
206
|
print BAKFILE $self->{OLDCONTENTS}; |
97
|
1
|
|
|
|
|
15
|
close (BAKFILE); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |