line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::MultiCat; |
2
|
1
|
|
|
1
|
|
25507
|
use 5.008; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
40
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
4
|
|
|
|
|
|
|
# use -w; -- replaced by the better... |
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
56
|
|
6
|
|
|
|
|
|
|
# require Exporter; |
7
|
|
|
|
|
|
|
# our @ISA = qw(Exporter); |
8
|
|
|
|
|
|
|
# our %EXPORT_TAGS = ( 'all' => [qw(multicat)] ); |
9
|
|
|
|
|
|
|
# our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
10
|
|
|
|
|
|
|
# our @EXPORT = qw(); |
11
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# use vars qw(@f $f @ar $ar $fout); |
14
|
1
|
|
|
1
|
|
13349
|
use subs qw(new multicat _multicat_error); |
|
1
|
|
|
|
|
38
|
|
|
1
|
|
|
|
|
8
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
1
|
|
|
1
|
|
4558
|
my $class = shift; |
18
|
1
|
|
|
|
|
2
|
my($self)= {}; |
19
|
1
|
|
|
|
|
3
|
bless ($self, $class); |
20
|
|
|
|
|
|
|
# multicat($ar); |
21
|
1
|
|
|
|
|
3
|
return ($self); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub multicat { |
25
|
1
|
|
|
1
|
|
117
|
use vars qw(@f $f $ar @ar $fout $self); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
718
|
|
26
|
1
|
|
|
1
|
|
244
|
($self, $ar) = @_; |
27
|
|
|
|
|
|
|
#Get the name of the site description file, open it, or open default multicat.dat |
28
|
1
|
50
|
|
|
|
5
|
if ($ar) { |
29
|
1
|
50
|
|
|
|
45
|
open(IN, $ar ) || _multicat_error('open', 'file'); |
30
|
|
|
|
|
|
|
} else { |
31
|
0
|
0
|
|
|
|
0
|
open(IN, "multicat.dat") || _multicat_error('open', 'file', 'multicat.dat'); |
32
|
|
|
|
|
|
|
} |
33
|
1
|
|
|
|
|
39
|
@f = ; |
34
|
1
|
50
|
|
|
|
14
|
close IN || _multicat_error('close', 'file', 'multicat.dat'); |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
4
|
foreach $f (@f){ |
37
|
|
|
|
|
|
|
# take each line of the site description file |
38
|
19
|
|
|
|
|
24
|
my (@splitLine, $ofi, $ifi); |
39
|
|
|
|
|
|
|
|
40
|
19
|
|
|
|
|
67
|
$f =~ s/#.*//; |
41
|
|
|
|
|
|
|
# strip comments |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# @splitLine=split(/ +/, $f); |
44
|
19
|
50
|
|
|
|
37
|
if($f) {@splitLine = split(' ', $f);} |
|
19
|
|
|
|
|
42
|
|
45
|
|
|
|
|
|
|
# split the line, at any number of space characters, into an array |
46
|
19
|
100
|
|
|
|
41
|
if (@splitLine) {$ofi = pop(@splitLine); } |
|
3
|
|
|
|
|
6
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# remove last item in line, the output filename; ('pop' it),dddd |
49
|
|
|
|
|
|
|
# leaving the rest of the line in @splitline. |
50
|
19
|
100
|
|
|
|
49
|
if (@splitLine){ |
51
|
|
|
|
|
|
|
# test because multicat.dat might have empty lines |
52
|
|
|
|
|
|
|
# and throw an error otherwise. |
53
|
3
|
50
|
|
|
|
550620
|
open(OUT, ">$ofi") || _multicat_error('opensk', 'file', $ofi); |
54
|
|
|
|
|
|
|
#open line's output file, the last filename on the line |
55
|
3
|
|
|
|
|
21
|
foreach $ifi (@splitLine) { |
56
|
|
|
|
|
|
|
# print "-$ifi-"; |
57
|
|
|
|
|
|
|
# take each remaining filename from the line |
58
|
9
|
50
|
|
|
|
313
|
open(XIN, "<$ifi")|| _multicat_error('open', 'file', $ifi); |
59
|
9
|
|
|
|
|
297
|
my @dat = ; |
60
|
|
|
|
|
|
|
# write that file's data, in order read in, |
61
|
|
|
|
|
|
|
# to the line's output file |
62
|
9
|
|
|
|
|
66
|
print OUT "@dat\n"; |
63
|
9
|
50
|
|
|
|
1555
|
close XIN || _multicat_error('close', 'file', $ifi); |
64
|
|
|
|
|
|
|
} |
65
|
3
|
50
|
|
|
|
188
|
close OUT || _multicat_error('close', 'file', $ofi); #close line's output file |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
1
|
|
|
|
|
14
|
return 1; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _multicat_error{ |
72
|
0
|
|
|
0
|
|
|
print "problem, can't $_[0] a $_[1], named $_[2]"; |
73
|
0
|
|
|
|
|
|
exit; # or comment this line out and do not exit |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
__END__ |