-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit.pl
More file actions
71 lines (63 loc) · 1.39 KB
/
Copy pathsplit.pl
File metadata and controls
71 lines (63 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#! /usr/bin/perl
use strict;
use warnings;
binmode(STDOUT);
my @fn;
my $fndef = 'x' x 30;
if ($#ARGV != 1){
print STDERR "perl split.pl (data.base) (outdir)\n";
exit;
}
my ($database, $outdir) = @ARGV;
{
my $f = 1;
my $fn = '00head';
my $c = '';
open my $fr, '<', $database or die;
binmode($fr);
while(<$fr>){
my $t = substr($_, 0, 1);
# if($t eq "\n"){
# if($t eq "\n" || $t eq '#'){
# next;
# }
if($f == 1){
if($t eq "\t" || $t eq "\n" || $t eq '#'){
$c .= $_;
next;
}
{
$f = 0;
open my $fw, '>', $outdir . '/' . $fn or die $!;
binmode($fw);
print $fw $c;
close $fw;
$c = '';
$fn = $fndef;
}
}
$c .= $_;
if($t eq "\t"){
chomp $fn;
printf "data/%s\n", $fn;
$f = 1;
next;
} else {
if($t eq '' || $t eq '~'){
next;
}
s/[.?* ]//g;
s/[^-A-Za-z]//g;
if($_ ne '' and length $fn > length $_){
$fn = $_;
}
}
}
close $fr;
{
open my $fw, '>', $outdir . '/' . $fn or die;
binmode($fw);
print $fw $c;
close $fw;
}
}