in reply to Array size too big?

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

Replies are listed 'Best First'.
Re^2: Array size too big?
by JillB (Novice) on Nov 20, 2017 at 00:19 UTC

    Thanks for this, Dave, I appreciate the time and effort you have taken to examine and respond. My Perl.exe, as seen on the screen image I referred to, is located as : c:\Dwimperl\usr\bin\Perl.exe My problem is this is only a small test GEDCOM file that I am reading. My main file is 9,000 records long :( Looks like I will need to alter my programming strategy and deal with a few lines at a time. regards, Jill