in reply to Re: Perl's __LINE__ off by 2 (Introspection)
in thread Perl's __LINE__ off by 2

The contents will be much more clear if you $Data::Dumper::Useqq=1; before the say Dumper

Replies are listed 'Best First'.
Re^3: Perl's __LINE__ off by 2
by LanX (Saint) on Aug 26, 2025 at 10:20 UTC
    indeed, but I would use both options to be sure about differing interpretations of CR LF

    4 5 6 $VAR1 = [ "use v5.12; \n", "use warnings;\n", "use Data::Dumper;\n", "say __LINE__;\n", "say __LINE__;\n", "say __LINE__;\n", "\n", "\n", "seek DATA,0,0;\n", "my \@lines = <DATA>;\n", "\$Data::Dumper::Useqq=1;\n", "say Dumper \\\@lines;\n", "\n", "__DATA__\n" ];

    Additionally one could run the file in the debugger and use the command 'v' or inspect @DB::dbline

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery

      Not sure what you mean? Dumper doesn't AFAIK have interpretations of CR LF, it is just showing the data, either outputting it raw (for the CRLF-relevant characters) or as escapes with Useqq, where \r means chr(0x13) and \n means chr(0x10) (assuming non-EBCDIC). If perl is opening the source in text mode, a binmode *DATA; before the seek/read may be good (don't know if that even works or if *DATA is somehow magic in a way that prevents changing layers).

        > Not sure what you mean?

        see Re: Perl's __LINE__ off by 2

        The OP thinks that he has a mix of newlines in his source, leading to different line interpretations by Perl and his editor.

        I'm pretty sure that <DATA> gives me the lines the same way the compiler sees them.

        A dump OTOH might add another layer of confusion.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        see Wikisyntax for the Monastery