annotate rapsodyn/SplitFile2x.pl @ 2:761fecc07fa9 draft

Uploaded
author mcharles
date Thu, 11 Sep 2014 03:10:47 -0400
parents 442a7c88b886
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
1 #!/usr/bin/perl
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
2 use strict;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
3 use warnings;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
4
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
5 my $in = $ARGV[0];
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
6 my $NB_LINE_GROUP = $ARGV[1];
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
7 my $NB_FILE = 2;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
8 my $out1 = $ARGV[2];
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
9 my $out2 = $ARGV[3];
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
10
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
11 if (!$NB_LINE_GROUP){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
12 $NB_LINE_GROUP=4;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
13 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
14
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
15 if (!$NB_FILE){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
16 $NB_FILE=2;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
17 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
18
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
19 my $file_nb = 1;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
20
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
21 my @in;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
22 my $current_aggregate;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
23 open(IN, $in) or die ("Can't open $in\n");
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
24 while (my $line =<IN>){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
25 $current_aggregate = $line;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
26 my $nb_line=1;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
27 if ($NB_LINE_GROUP>1){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
28 while (my $add_line = <IN>){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
29 $current_aggregate .= $add_line;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
30 $nb_line++;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
31 if ($nb_line == $NB_LINE_GROUP){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
32 last;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
33 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
34 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
35 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
36 push (@in,$current_aggregate);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
37 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
38 close (IN);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
39
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
40 open (OUT1,">$out1") or die ("Can't open $out1");
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
41 open (OUT2,">$out2") or die ("Can't open $out2");
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
42
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
43 for (my $i=0;$i<=$#in;$i++){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
44 if ($i <= $#in/2){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
45 print OUT1 $in[$i];
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
46 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
47 else {
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
48 print OUT2 $in[$i];
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
49 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
50
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
51
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
52 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
53 close (OUT1);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
54 close (OUT2);