in reply to RE: Re (tilly) 1: 'no such file' when it's there.
in thread 'no such file' when it's there.

$. is the line number on the most recent filehandle read, and reset when the file is closed. You're now wandering through an array, not reading a file, so the $. won't make any sense or correlation. If you want an element number, do this:
for my $line (0..$#newfile) { .. access $newfile[$line] .. if error, talk about "line number $line" }

P.S. in the future, please enclose your code in CODE tags. Much easier to read.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
RE: RE: RE: Re (tilly) 1: 'no such file' when it's there.
by jptxs (Curate) on Aug 31, 2000 at 08:13 UTC

    CODE! i was wondering how y'all did that...

    is there any advatage to using that over simply using a $line_num++ for each line i go through?

      Fewer chances for programmer error.

      Considering that I tend to be the programmer making the mistakes, I happen to like this one. :-)