By writing my @ary= as part of the loop, the array will be cleared out on each iteration, with the effect that if your script finishes with a blank line the array will be replaced with split " ","" on the last iteration.

Sorry but as you said earlier I beg to differ. :-)

There is something deeper and funkier happening than what you have stated is going on. I dont claim to know what it is but its definately not the 'if the last line is blank' problem. You might want to take a look at my other reply in this thread for a couple of examples, but try this on for size:

my @ary=split(" ",$_) while (<DATA>); print "@ary"; __DATA__ These are words

Now this DOESNT work. Even though there is no blank line. (use an editor that can show you newlines to make sure.) Now make one tiny change and what happens

my @ary; @ary=split(" ",$_) while (<DATA>); print "@ary"; __DATA__ These are words
Voila it works! So now we KNOW that it isnt anything to do with those darn sneaky hidden blank lines.

Quite frankly until somebody at the wizard/god level tells me this isnt a bug and explains exactly what is going on my money is on the cockroaches...

Yves
--
You are not ready to use symrefs unless you already know why they are bad. -- tadmc (CLPM)


In reply to Sorry but 'last line is blank' doesnt wash.. by demerphq
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.