annotate rapsodyn/SplitFile4x.pl @ 14:93e6f2af1ce2 draft

Uploaded
author mcharles
date Mon, 26 Jan 2015 18:10:52 -0500
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 = 4;
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 my $out3 = $ARGV[4];
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
11 my $out4 = $ARGV[5];
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
12
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
13 if (!$NB_LINE_GROUP){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
14 $NB_LINE_GROUP=4;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
15 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
16
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
17 if (!$NB_FILE){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
18 $NB_FILE=4;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
19 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
20
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
21 my $file_nb = 1;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
22
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
23 my @in;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
24 my $current_aggregate;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
25 open(IN, $in) or die ("Can't open $in\n");
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
26 while (my $line =<IN>){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
27 $current_aggregate = $line;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
28 my $nb_line=1;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
29 if ($NB_LINE_GROUP>1){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
30 while (my $add_line = <IN>){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
31 $current_aggregate .= $add_line;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
32 $nb_line++;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
33 if ($nb_line == $NB_LINE_GROUP){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
34 last;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
35 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
36 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
37 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
38 push (@in,$current_aggregate);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
39 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
40 close (IN);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
41
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
42 open (OUT1,">$out1") or die ("Can't open $out1");
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
43 open (OUT2,">$out2") or die ("Can't open $out2");
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
44 open (OUT3,">$out3") or die ("Can't open $out3");
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
45 open (OUT4,">$out4") or die ("Can't open $out4");
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
46
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
47
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
48 for (my $i=0;$i<=$#in;$i++){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
49 if ($i <= $#in/4){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
50 print OUT1 $in[$i];
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
51 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
52 elsif ($i <= $#in/2){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
53 print OUT2 $in[$i];
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
54 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
55 elsif ($i <= $#in*3/4){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
56 print OUT3 $in[$i];
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
57 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
58 elsif ($i <= $#in){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
59 print OUT4 $in[$i];
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
60 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
61 else {
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
62
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
63 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
64
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
65
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
66 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
67 close (OUT1);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
68 close (OUT2);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
69 close (OUT3);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
70 close (OUT4);