in reply to Here there be cammels!

Apparently the extra "<$fh> line X" message is added by Perl_mess_sv in util.c and is based on PL_last_in_gv. Apparently that is only set by readline, tell, eof and seek. If the file you want to report the line numbers on is closed, it doesn't seem like trying to trick/hack Perl into generating that extra message for you is worth it, and it's much cleaner to implement a message yourself.

Replies are listed 'Best First'.
Re^2: Here there be camels!
by LanX (Saint) on Feb 28, 2015 at 23:43 UTC
    Furthermore does readline depend on the chunk-size determined of the input-record-separator $/

    The only possibility to fake this is to reopen and reread line by line.

    I have no idea how seek could be able to set $. without lots of magic.

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

    PS: Je suis Charlie!

      I have no idea how seek could be able to set $. without lots of magic.

      It doesn't update $. itself; it does update PL_last_in_gv.

      open my $fa, '<', '/etc/passwd' or die $!; open my $fb, '<', '/etc/group' or die $!; <$fa>; $.=9; <$fa>; warn "One"; <$fb>; $.=17; <$fb>; warn "Two"; seek $fa,256,1; warn "Three"; seek $fb,256,1; warn "Four"; <$fa>; warn "Five"; <$fb>; warn "Six"; __END__ One at - line 3, <$fa> line 10. Two at - line 4, <$fb> line 18. Three at - line 5, <$fa> line 10. Four at - line 6, <$fb> line 18. Five at - line 7, <$fa> line 11. Six at - line 8, <$fb> line 19.

      See pp_sysseek in pp_sys.c.