logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Eval::LineNumbers - Add line numbers to heredoc blocks that contain perl source code

Author

       Original author: David Muir Sharnoff

       Current maintainer: Graham Ollis <plicease@cpan.org>

       Contributors:

       Olivier Mengué (DOLMEN)

       David Steinbrunner (dsteinbrunner)

       Alexey Ugnichev (thaewrapt)

Description

       Add a "#line "this-file" 392" comment to heredoc/hereis text that is going to be eval'ed so that error
       messages will point back to the right place.

       Please note: when you embed "\n" in your code, it gets expanded in double-quote hereis documents so it
       will mess up your line numbering.  Use "\\n" instead when you can.

   CallerLevelExample
       The second form of eval_line_numbers where a caller-level is provided is for the situation where the code
       is generated in one place and eval'ed in another place.  The caller level should be the number of stack
       levels between where the heredoc was created and where it is eval'ed.

        sub example {
          return <<END_HEREIS
            code
       END_HEREIS
        }

        eval eval_line_numbers(1, example())

Functions

       All functions are exportable on request, but not by default.

   eval_line_numbers
        eval eval_line_numbers($code);
        eval eval_line_numbers($caller_level, $code);

   eval_line_numbers_offset
        eval_line_numbers_offset $offset;

       Sets the offset, which is by default 1.  The offset is file scoped.  This is useful if you want to pass a
       string without a heredoc.  For example:

        eval_line_numbers_offset 0;
        eval eval_line_numbers q{
          die "here";
        };

Name

       Eval::LineNumbers - Add line numbers to heredoc blocks that contain perl source code

Synopsis

        use Eval::LineNumbers qw(eval_line_numbers);

        eval eval_line_numbers(<<END_HEREIS);
          code
        END_HEREIS

        eval eval_line_numbers($caller_level, $code)

Version

       version 0.35

See Also