in reply to Re: Here there be cammels!
in thread Here there be cammels!

> And yet, it's a hack.

Looks like a bug for me, though DATA is closed it's reported at FOUR.

Only b/c a line-number is set.

> Better to implement the message yourself.

Well, yeah, undocumented behavior. :)

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)

PS: Je suis Charlie!

Replies are listed 'Best First'.
Re^3: Here there be camels!
by Discipulus (Canon) on Mar 01, 2015 at 08:51 UTC
    I do not think is a bug: is a edge case of use of very particular features...
    diamond <> never close the handle and __DATA__ is very near to be $0 in this case (if i remember you can seek it and print the main program too). Because you can adjust $. and you had not closed DATA handle you end with the beahviour observed.
    from perldata
    Text after __DATA__ may be read via the filehandle PACKNAME::DATA , where PACKNAME is the package that was current when the __DATA__ token was encountered. The filehandle is left open pointing to the line after __DATA__. The program should close DATA when it is done reading from it.
    
    PS. thanks for the line directive hint: never eard about..
    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

      Using DATA was just an example, the same thing happens on a normal filehandle too.

      system 'echo "foo" >/tmp/blah'; open my $fh, '<', '/tmp/blah' or die $!; while (<$fh>) { chomp; warn "<$_>"; } warn "One"; $. = 123; warn "Two"; close $fh; warn "Three"; $. = 456; warn "Four"; __END__ <foo> at - line 3, <$fh> line 1. One at - line 4, <$fh> line 1. Two at - line 6, <$fh> line 123. Three at - line 8. Four at - line 10, <$fh> line 456.

      So LanX is probably right about it being more of a bug than an obscure feature :-)