diff rapsodyn/SplitFile2x.pl @ 0:442a7c88b886 draft

Uploaded
author mcharles
date Wed, 10 Sep 2014 09:18:15 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rapsodyn/SplitFile2x.pl	Wed Sep 10 09:18:15 2014 -0400
@@ -0,0 +1,54 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+my $in = $ARGV[0];
+my $NB_LINE_GROUP = $ARGV[1];
+my $NB_FILE = 2;
+my $out1 = $ARGV[2];
+my $out2 = $ARGV[3];
+
+if (!$NB_LINE_GROUP){
+	$NB_LINE_GROUP=4;
+}
+
+if (!$NB_FILE){
+	$NB_FILE=2;
+}
+
+my $file_nb = 1;
+
+my @in;
+my $current_aggregate;
+open(IN, $in) or die ("Can't open $in\n");
+while (my $line =<IN>){
+	$current_aggregate = $line;
+	my $nb_line=1;
+	if ($NB_LINE_GROUP>1){
+		while (my $add_line = <IN>){
+			$current_aggregate .= $add_line;
+			$nb_line++;
+			if ($nb_line == $NB_LINE_GROUP){
+				last;
+			}
+		}
+	}	
+	push (@in,$current_aggregate);
+}
+close (IN);
+
+open (OUT1,">$out1") or die ("Can't open $out1");
+open (OUT2,">$out2") or die ("Can't open $out2");
+
+for (my $i=0;$i<=$#in;$i++){
+	if ($i <= $#in/2){
+		print OUT1 $in[$i];
+	}
+	else {
+		print OUT2 $in[$i];
+	}
+
+
+}  
+close (OUT1);
+close (OUT2);