I wrote a program to order some output I had from another file. (Tab delimited; first column is the file name; I'm looking for certain letters in the file name). WHen I run this code, I get an error saying 'No comman allowed after file handle, line 42'. The line in question will be marked.

I don't understand it, because $i_file opens normally, and the only difference between $i_ and $o_file is the '>'. I don't even know what comma it's talking about!

#!/usr/bin/perl use warnings; use strict; my $i_file = "faster_averages.txt"; my $o_file = ">ordered_averages.txt"; my @i; my $j = 0; my @CCFN; my @CCFN_NT; my @EBG; my @EBGFN; my @PR; my @PRFN; my @BL; my @BLSTDG; my @BLSTDGG; my @output; open(IN, $i_file) or die "$i_file failed to open: $!"; my @lines = <IN>; close IN; for my $file ((split /\t/, @lines)[0]) { if($file =~ /CCFN\d+NT/) { $CCFN_NT[$i[0]++] = $lines[$j] } if($file =~ /CCFN/) { $CCFN[$i[1]++] = $lines[$j] } if($file =~ /EBGFN/) { $EBGFN[$i[2]++] = $lines[$j] } if($file =~ /EBG/) { $EBG[$i[3]++] = $lines[$j] } if($file =~ /PRFN/) { $PRFN[$i[4]++] = $lines[$j] } if($file =~ /PR/) { $PR[$i[5]++] = $lines[$j] } if($file =~ /BLSTDGG/) { $BLSTDGG[$i[6]++] = $lines[$j] } if($file =~ /BLSTDG/) { $BLSTDG[$i[7]++] = $lines[$j] } if($file =~ /BL/) { $BL[$i[8]++] = $lines[$j] } $j++; } @output = (@CCFN,@CCFN_NT,@EBG,@EBGFN,@PR,@PRFN,@BL,@BLSTDG,@BLSTDGG); ######## # Right here open(OUT, $o_file) or die "$o_file failed to be created: $!"; # $o_file defined above ######## print OUT, @output; close OUT;

In reply to Help with perl error message by dimmesdale

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.