in reply to Sorry but 'last line is blank' doesnt wash..
in thread Getting data out of __DATA__ and __END__
I threw this in a debugger to see what exactly happens where. With this code..
I set a breakpoint upon reaching the suspect line. When it hits the line, the my variable @ary is created. It's empty. This is done before the evaluation of the expression. Unfortunately the debugger I was using won't show the reiteration of that line. But needless to say, when I stepped off that line, @ary was still empty.my @ary=split(" ",$_) while (<DATA>); print "@ary"; __DATA__ These are words These are more words
Next, I used
I set the breakpoint on the my declaration. As before, when I hit that line, @ary was created. When I left the line, it contained the last line of text, each word in an array element.my @ary; @ary=split(" ",$_) while (<DATA>); print "@ary"; __DATA__ These are words These are more words
What that information, here's my opinion:
Each time the line in question is accessed, @ary is redeclared (blank). This even happens when the line is executed just for <DATA> to return false. So the last iteration redeclares @ary, there's no more DATA and the program moves on.
Is that a bug? I'll let someone else answer that :)
Rich
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Monks, I think we have a winner!
by demerphq (Chancellor) on Sep 10, 2001 at 22:17 UTC | |
|
Re: Re: Sorry but 'last line is blank' doesnt wash..
by George_Sherston (Vicar) on Sep 10, 2001 at 23:19 UTC |