I hope you use strict and warnings? Did you debug?
1 - # think its a bad idea to start 2 - # with a false value here 3 - $n=0; 4 - 5 - open(OUT,">$n.out"); 6 - 7 - while(<>) { #where do you read from really? 8 - print OUT; 9 - 10- # that doesn't match anything, 11- # it will always return true 12- if (/foo/) { 13- # why do you do that? use a sub that returns 14- # a filehandle (or a reference to it) 15- close(OUT); 16- $n++; 17- open(OUT,">$n.out"); 18- } 19- } 20- close(OUT); 21

Have a nice day
All decision is left to your taste

In reply to Re: Parsing large files by little
in thread Parsing large files by Spica

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.