Mercurial > repos > mcharles > rapsosnp
comparison rapsodyn/SplitFile4x.pl @ 0:442a7c88b886 draft
Uploaded
author | mcharles |
---|---|
date | Wed, 10 Sep 2014 09:18:15 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:442a7c88b886 |
---|---|
1 #!/usr/bin/perl | |
2 use strict; | |
3 use warnings; | |
4 | |
5 my $in = $ARGV[0]; | |
6 my $NB_LINE_GROUP = $ARGV[1]; | |
7 my $NB_FILE = 4; | |
8 my $out1 = $ARGV[2]; | |
9 my $out2 = $ARGV[3]; | |
10 my $out3 = $ARGV[4]; | |
11 my $out4 = $ARGV[5]; | |
12 | |
13 if (!$NB_LINE_GROUP){ | |
14 $NB_LINE_GROUP=4; | |
15 } | |
16 | |
17 if (!$NB_FILE){ | |
18 $NB_FILE=4; | |
19 } | |
20 | |
21 my $file_nb = 1; | |
22 | |
23 my @in; | |
24 my $current_aggregate; | |
25 open(IN, $in) or die ("Can't open $in\n"); | |
26 while (my $line =<IN>){ | |
27 $current_aggregate = $line; | |
28 my $nb_line=1; | |
29 if ($NB_LINE_GROUP>1){ | |
30 while (my $add_line = <IN>){ | |
31 $current_aggregate .= $add_line; | |
32 $nb_line++; | |
33 if ($nb_line == $NB_LINE_GROUP){ | |
34 last; | |
35 } | |
36 } | |
37 } | |
38 push (@in,$current_aggregate); | |
39 } | |
40 close (IN); | |
41 | |
42 open (OUT1,">$out1") or die ("Can't open $out1"); | |
43 open (OUT2,">$out2") or die ("Can't open $out2"); | |
44 open (OUT3,">$out3") or die ("Can't open $out3"); | |
45 open (OUT4,">$out4") or die ("Can't open $out4"); | |
46 | |
47 | |
48 for (my $i=0;$i<=$#in;$i++){ | |
49 if ($i <= $#in/4){ | |
50 print OUT1 $in[$i]; | |
51 } | |
52 elsif ($i <= $#in/2){ | |
53 print OUT2 $in[$i]; | |
54 } | |
55 elsif ($i <= $#in*3/4){ | |
56 print OUT3 $in[$i]; | |
57 } | |
58 elsif ($i <= $#in){ | |
59 print OUT4 $in[$i]; | |
60 } | |
61 else { | |
62 | |
63 } | |
64 | |
65 | |
66 } | |
67 close (OUT1); | |
68 close (OUT2); | |
69 close (OUT3); | |
70 close (OUT4); |