comparison rapsodyn/SplitFile10x.pl @ 7:3f7b0788a1c4 draft

Uploaded
author mcharles
date Tue, 07 Oct 2014 10:34:34 -0400
parents
children
comparison
equal deleted inserted replaced
6:1776b8ddd87e 7:3f7b0788a1c4
1 #!/usr/bin/perl
2 #V1.0.0
3 use strict;
4 use warnings;
5
6 my $in = $ARGV[0];
7 my $NB_LINE_GROUP = $ARGV[1];
8 my $out1 = $ARGV[2];
9 my $out2 = $ARGV[3];
10 my $out3 = $ARGV[4];
11 my $out4 = $ARGV[5];
12 my $out5 = $ARGV[6];
13 my $out6 = $ARGV[7];
14 my $out7 = $ARGV[8];
15 my $out8 = $ARGV[9];
16 my $out9 = $ARGV[10];
17 my $out10 = $ARGV[11];
18
19 my $file_nb = 1;
20
21 my @in;
22 my $current_aggregate;
23 open(IN, $in) or die ("Can't open $in\n");
24 while (my $line =<IN>){
25 $current_aggregate = $line;
26 my $nb_line=1;
27 if ($NB_LINE_GROUP>1){
28 while (my $add_line = <IN>){
29 $current_aggregate .= $add_line;
30 $nb_line++;
31 if ($nb_line == $NB_LINE_GROUP){
32 last;
33 }
34 }
35 }
36 push (@in,$current_aggregate);
37 }
38 close (IN);
39
40 open (OUT1,">$out1") or die ("Can't open $out1");
41 open (OUT2,">$out2") or die ("Can't open $out2");
42 open (OUT3,">$out3") or die ("Can't open $out3");
43 open (OUT4,">$out4") or die ("Can't open $out4");
44 open (OUT5,">$out5") or die ("Can't open $out5");
45 open (OUT6,">$out6") or die ("Can't open $out6");
46 open (OUT7,">$out7") or die ("Can't open $out7");
47 open (OUT8,">$out8") or die ("Can't open $out8");
48 open (OUT9,">$out9") or die ("Can't open $out9");
49 open (OUT10,">$out10") or die ("Can't open $out10");
50
51
52 for (my $i=0;$i<=$#in;$i++){
53 if ($i <= $#in * 1 /10){
54 print OUT1 $in[$i];
55 }
56 elsif ($i <= $#in* 2 /10){
57 print OUT2 $in[$i];
58 }
59 elsif ($i <= $#in*3/10){
60 print OUT3 $in[$i];
61 }
62 elsif ($i <= $#in*4/10){
63 print OUT4 $in[$i];
64 }
65 elsif ($i <= $#in*5/10){
66 print OUT5 $in[$i];
67 }
68 elsif ($i <= $#in*6/10){
69 print OUT6 $in[$i];
70 }
71 elsif ($i <= $#in*7/10){
72 print OUT7 $in[$i];
73 }
74 elsif ($i <= $#in*8/10){
75 print OUT8 $in[$i];
76 }
77 elsif ($i <= $#in*9/10){
78 print OUT9 $in[$i];
79 }
80 elsif ($i <= $#in*10/10){
81 print OUT10 $in[$i];
82 }
83 else {
84
85 }
86
87
88 }
89 close (OUT1);
90 close (OUT2);
91 close (OUT3);
92 close (OUT4);
93
94