in reply to __DATA__ Inconsistency

I'd add in use warnings; as a matter of course, but that won't make any difference to your problem.

I'd $test .= $_ while <DATA>;, but that won't make any difference either (although it means you don't need to init $test in the previous line).

Rather than the while loop I'd more likely write: my $test = join '', <DATA>;, but that won't make any difference either (Update: actually if I were a couple more cups of coffee through the day I'd use $/ as moritz suggests).

In fact, I can't see how the code you've shown could fail in the manner you describe. Does your sample code actually fail, or have you golfed it down from a larger piece of code that does fail? If the sample is golfed, try generating a sample that actually does fail and show us that.


Perl reduces RSI - it saves typing

Replies are listed 'Best First'.
Re^2: __DATA__ Inconsistency
by bichonfrise74 (Vicar) on Oct 02, 2008 at 23:44 UTC
    It does fail and it would add in the $_ some messages that occurred early on, but again it is so inconsistent. I wish I could re-produce it.

    What I did was I "initialized" $_ to be safe.
    $test = qq(); $_ = qq(); $test = $test . $_ while(<DATA>);

      In your sample code there is no "early on". Show us the actual code that is failing rather than what you consider to be a representative snippet. The code you have shown can not fail in the way you describe!


      Perl reduces RSI - it saves typing