in reply to I don't understand why I'm getting an unitialized value warning

I'm a little confused as to the purpose of this snippet. Are records in your file separated by an extra newline? I ask because it *appears* that your code tests each line in @lines to see if it only contains "\n". If so, it pops the last line off of the array (probably not what you want), decreases the number of lines expected (probably what you want) and decrements the loop index (which will cause the loop to hit the newline again, and keep popping off good lines from your array, probably the source of your error message).

If you want to get rid of blank lines more easily, one idea is:

#!C:\Perl\bin\perl.exe -w use strict; # I'm a masochist my $file = shift || 'foo.txt'; # why not my @lines; open(SESAME, $file) || die "Cannot open $file: $!"; # save debuggin +g time while (<SESAME>) { chomp; next unless $_; push @lines, $_; } close(SESAME) || die "Cannot close $file: $!"; my $total = @lines; print "There are $total records in $file\n";
Not too bad. I can make it shorter, though:
{ local *SESAME; # localizing a filehandle saves debugging ti +me too open (SESAME, $file) || die "Foo: $!"; local $/ = "\n\n"; # "line" delimiter is now two newlines @lines = <SESAME>; close (SESAME) || die "Bar: $!"; }
Bingo! One record per line in the array. You could also throw a split in there on newlines if you wanted records stored in the array one line at a time.