Ok, I'm confused with this one, namely because it used to work for a start! Don't have the faintest idea what has gone wrong now.
I have a text file ... looks similar to this other than it actually has 13 columns
.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
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.
I first write a perl program that will give a .txt file like this
1 10 2 1 10 3 1 10 4 1 10 5 1 10 6 1 10 7 1 10 8 etc
I then feed this text file into the following perl script
#! /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"); }
Which then calls this one.
#! /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"; }

It doesnt work and I am straching my head as to why. I use the count variable because .. although it used to work for when column = 0, it doesnt now, at all. But the count variable doesnt increase at all, so it doesnt do what I think it should be doing. The files are being created ok but all 13 columns are being printed each time .. so I have 120 files that are exactly the same.
I just know this has to be a silly mistake but I can't find it. Any suggestions much appreciated.

In reply to what on earth is going on? by Angharad

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.