Re: [SPOILER] Perl Quiz of the Week #24 (Turing Machine simulation)

Ronald J Kimball <[email protected]>
Newsgroups gmane.comp.lang.perl.qotw.discuss
Message-ID <[email protected]>
On Fri, Sep 17, 2004 at 04:06:57PM +0200, Jurgen Pletinckx wrote:

> I am somewhat befuddled by the behaviour of $. in my 'die'
> clause at line 46 - this reports the last line number of the
> program file, rather than the current line, as I would expect
> it to. Anyone care to clue me in?

This:

for (<PROG>) {

reads in the entire file before starting the loop.  You should use:

while (<PROG>) {

instead.


Ronald
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.