Angharad has asked for the wisdom of the Perl Monks concerning the following question:
Out of those 13 columns I want to chose any 10 of them and then print them. So, one file might not have columns 1 3 and 6 . Another might not have 4, 7 and 9. I want to create files for all combinations of 10 columns .. making 120 files in total..55 0.68 0.39 0.69 0.42 0.43 0.52 0.61 0.13 0.1 0.09 0.06 0.08 0.12 0.07 0.08 0.04 0.01 0.13 0.04 0.1 0.07 0.03 0.02 0.08 0.03 0.11 0.03 0.08 0.05 0.07 0.02
I then feed this text file into the following perl script1 10 2 1 10 3 1 10 4 1 10 5 1 10 6 1 10 7 1 10 8 etc
Which then calls this one.#! /usr/bin/perl $combofile = $ARGV[0]; $spectralfile = $ARGV[1]; $diroutput = $ARGV[2]; $without = "spectrawithout"; $txt = ".txt"; open(COMBO, "$combofile") || die "Error: Can't open $combofile: $!\n"; while(<COMBO>) { @combo = split; $var1 = $combo[0]; $var2 = $combo[1]; $var3 = $combo[2]; $output = "$without$var1$var2$var3$txt"; system("chosespectraldata.pl $spectralfile $var1 $var2 $var3 > $di +routput$output"); }
#! /usr/bin/perl $spectralfile = $ARGV[0]; $var1 = $ARGV[1]; $var2 = $ARGV[2]; $var3 = $ARGV[3]; $count = 0; open(SPEC, "$spectralfile") || die "ERROR: Can't open $spectralfile FI +LE for reading: $!\n"; foreach my $line (<SPEC>) { chomp $line; #@array = split(/\t/,$line); @array = split(/\,/,$line); for($i = 0; $i<@array; $i++) { $count = $i++; if(($count != $var1) || ($count !=$var2) || ($count !=$var3)) { print "$count $var1 $var2 $var3\n"; print "$array[$i],\t"; } } print "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: what on earth is going on?
by eric256 (Parson) on Nov 10, 2005 at 17:15 UTC | |
by polettix (Vicar) on Nov 10, 2005 at 17:25 UTC | |
by Angharad (Pilgrim) on Nov 10, 2005 at 17:25 UTC | |
|
Re: what on earth is going on?
by planetscape (Chancellor) on Nov 10, 2005 at 17:30 UTC | |
|
Re: what on earth is going on?
by ikegami (Patriarch) on Nov 10, 2005 at 17:24 UTC | |
|
Re: what on earth is going on?
by davidrw (Prior) on Nov 10, 2005 at 17:35 UTC | |
|
Re: what on earth is going on?
by blazar (Canon) on Nov 10, 2005 at 17:24 UTC | |
by inman (Curate) on Nov 10, 2005 at 17:45 UTC |