Mercurial > repos > mcharles > rapsosnp
view rapsodyn/SplitFile2x.pl @ 6:1776b8ddd87e draft
Uploaded
author | mcharles |
---|---|
date | Mon, 29 Sep 2014 03:02:16 -0400 |
parents | 442a7c88b886 |
children |
line wrap: on
line source
#!/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);