Well I'm definately not at the wizard/god level, but I think I might know what's really going on. It's up to others to call it a bug or not.

I threw this in a debugger to see what exactly happens where. With this code..

my @ary=split(" ",$_) while (<DATA>); print "@ary"; __DATA__ These are words These are more words
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.

Next, I used

my @ary; @ary=split(" ",$_) while (<DATA>); print "@ary"; __DATA__ These are words These are more words
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.

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


In reply to Re: Sorry but 'last line is blank' doesnt wash.. by rchiav
in thread Getting data out of __DATA__ and __END__ by George_Sherston

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.