comparison rapsodyn/SplitFile2x.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 = 2;
8 my $out1 = $ARGV[2];
9 my $out2 = $ARGV[3];
10
11 if (!$NB_LINE_GROUP){
12 $NB_LINE_GROUP=4;
13 }
14
15 if (!$NB_FILE){
16 $NB_FILE=2;
17 }
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
43 for (my $i=0;$i<=$#in;$i++){
44 if ($i <= $#in/2){
45 print OUT1 $in[$i];
46 }
47 else {
48 print OUT2 $in[$i];
49 }
50
51
52 }
53 close (OUT1);
54 close (OUT2);