Your scroll-back buffer isn't large enough to accommodate the entire output. If you're using a *nix environment, try this:

./myscript |wc -l

In other words, run your script, and pipe its output to wc -l, which will be a line count. It should be the size of $count plus one (because "no. of records: $count \n" is printed in-band. If you wish to make the header out of band, print it to STDERR, which won't be counted by wc.

I'll assert that wc -l will probably say "5175" (or something close). If it doesn't, your input file isn't as big as you think it is, or is using some other record separator other than a standard newline.

Your code above is correct, though would be better written like this:

my $file_in = "C:/Users/Joe/Documents/Geneaology/birdt.ged"; open my $FILE, '<', $file_in or die $!; while(<$FILE>) { print "$.\t$_"; } warn "no. of records read: $.\n";

...recognizing that you can't print a total number of records until you've gotten through the last one. Better, because it avoids slurping the entire file into memory all at once. Instead, it just reads in one record at a time, so it is less of a resource hog.

And now that I've looked more closely at your file name, it seems unlikely that you are using a *nix operating system, so wc -l probably isn't available to you unless you install something like CoreUtils: http://gnuwin32.sourceforge.net/packages/coreutils.htm. This does lead me to wonder why you have #!/usr/bin/perl at the top of your script. Does your Windows system have a program named perl living at C:\usr\bin?


Dave


In reply to Re: Array size too big? by davido
in thread Array size too big? by JillB

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.