I'm sorry if I made waste your time but (as I replied above) it wasn't possible for me to copy&paste the code. Also I thought it was really basic error that didn't require running to sort out since the problem is I don't know very well how to use references to functions.But I thank you for trying to fix it anyway, not everybody would do that. If the actual code is more usefull for you here it is:
#!/usr/bin/perl $fileName = $ARGV[0]; $windowSize = $ARGV[1]; $windowIncrement = $ARGV[2]; open(CPF, $fileName) or die ("Can't open file ", $fileName); @lines = <CPF>; close (CPF) or warn ("Unable to close ", $fileName); $n = @lines; $index = 0; @allNames; @allSeq; $nbTaxa; $nbGenes; #$lastLine = "start"; $alternatingIter = sub {return $_[0]}; $followedIter = sub {return (($_[0] % 10) - 1) }; $iter; chop $lines[0]; ($nbTaxa,$nbGenes)=split / +/, $lines[0]; &sorter ($lines[1]); if (((length $second) == 0) && ($first =~ /[AGTC]+/)){ $iter = $followedIter; chop ($first); $allSeq[$index]= $allSeq[$index].$first; print "TYPE: just sequence --> "; print "first:".$first."; second:".$second.";\n"; } elsif (((length $second) > 0) && ($first =~ /(\w)+/) && ($second +=~ /[AGTC]+/) ){ $iter = $alternatingIter; $allNames [$index] = $first; chop ($second); $allSeq [$index] = $second; $index++; print "TYPE: name + sequence --> "; print "first:".$first."; second:".$second.";\n"; } foreach $tmp (@lines[3..@lines]){ &sorter ($tmp); } sub sorter { $tmp = $_[0]; ($first, $second)= split / +/, $tmp; if (((length $second) == 0) && ($first =~ /[AGTC]+/)){ chop ($first); $allSeq[$index]= $allSeq[$index].$first; print "TYPE: just sequence --> "; print "first:".$first."; second:".$second.";\n"; } elsif (((length $second) > 0) && ($first =~ /(\w)+/) && ($second +=~ /[AGTC]+/) ){ $allNames [$index] = $first; chop ($second); $allSeq [$index] = $second; $index++; print "TYPE: name + sequence --> "; print "first:".$first."; second:".$second.";\n"; } elsif($first eq "\n"){ print "TYPE: do nothing --> "; print "first:".$first."; second:".$second.";\n"; } else{ print "TYPE: you have a problem with the format of file".$file +Name." --> "; print "first:".$first."; second:".$second.";\n"; } print "index: ".$index."\n"; }
I've cutted the parts that don't have anything to do with the problem so I'm almost certain it will run. Still, the problem is the same (using the iter reference) as i didn't understand what you fixed.

In reply to Re^2: using reference to subroutine by kotoko
in thread using reference to subroutine by kotoko

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.