Mercurial > repos > mcharles > rapsosnp
view rapsodyn/SplitFileUpTo10x.pl @ 15:56d328bce3a7 draft default tip
Uploaded
author | mcharles |
---|---|
date | Thu, 29 Jan 2015 08:54:06 -0500 |
parents | 0e7c6fe60646 |
children |
line wrap: on
line source
#!/usr/bin/perl #V1.0.0 use strict; use warnings; my $in = $ARGV[0]; my $NB_LINE_GROUP = $ARGV[1]; my $NB_FILE = $ARGV[2]; my $out1 = $ARGV[3]; my $out2 = $ARGV[4]; my $out3 = $ARGV[5]; my $out4 = $ARGV[6]; my $out5 = $ARGV[7]; my $out6 = $ARGV[8]; my $out7 = $ARGV[9]; my $out8 = $ARGV[10]; my $out9 = $ARGV[11]; my $out10 = $ARGV[12]; if (($NB_FILE<2)||($NB_FILE>10)){ print STDERR "File must be split in 2-10\n"; exit(0); } 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"); open (OUT3,">$out3") or die ("Can't open $out3"); open (OUT4,">$out4") or die ("Can't open $out4"); open (OUT5,">$out5") or die ("Can't open $out5"); open (OUT6,">$out6") or die ("Can't open $out6"); open (OUT7,">$out7") or die ("Can't open $out7"); open (OUT8,">$out8") or die ("Can't open $out8"); open (OUT9,">$out9") or die ("Can't open $out9"); open (OUT10,">$out10") or die ("Can't open $out10"); for (my $i=0;$i<=$#in;$i++){ if ($i <= $#in * 1 / $NB_FILE){ print OUT1 $in[$i]; } elsif ($i <= $#in * 2 / $NB_FILE){ print OUT2 $in[$i]; } elsif (($NB_FILE>=3)&&($i <= $#in * 3 / $NB_FILE)){ print OUT3 $in[$i]; } elsif (($NB_FILE>=4)&&($i <= $#in * 4 / $NB_FILE)){ print OUT4 $in[$i]; } elsif (($NB_FILE>=5)&&($i <= $#in * 5 / $NB_FILE)){ print OUT5 $in[$i]; } elsif (($NB_FILE>=6)&&($i <= $#in * 6 / $NB_FILE)){ print OUT6 $in[$i]; } elsif (($NB_FILE>=7)&&($i <= $#in * 7 / $NB_FILE)){ print OUT7 $in[$i]; } elsif (($NB_FILE>=8)&&($i <= $#in * 8 / $NB_FILE)){ print OUT8 $in[$i]; } elsif (($NB_FILE>=9)&&($i <= $#in * 9 / $NB_FILE)){ print OUT9 $in[$i]; } elsif (($NB_FILE>=10)&&($i <= $#in * 10 / $NB_FILE)){ print OUT10 $in[$i]; } else { } } close (OUT1); close (OUT2); close (OUT3); close (OUT4); close (OUT5); close (OUT6); close (OUT7); close (OUT8); close (OUT9); close (OUT10);