1Eval::LineNumbers(3)  User Contributed Perl Documentation Eval::LineNumbers(3)
2
3
4

NAME

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

SYNOPSIS

10        use Eval::LineNumbers qw(eval_line_numbes);
11
12        eval eval_line_numbers(<<END_HEREIS);
13          code
14        END_HEREIS
15
16        eval eval_line_numbers($caller_level, $code)
17

DESCRIPTION

19       Add a "#line "this-file" 392" comment to heredoc/hereis text that is
20       going to be eval'ed so that error messages will point back to the right
21       place.
22
23       Please note: when you embed "\n" in your code, it gets expanded in
24       double-quote hereis documents so it will mess up your line numbering.
25       Use "\\n" instead when you can.
26
27   Caller Level Example
28       The second form of eval_line_numbers where a caller-level is provided
29       is for the situation where the code is generated in one place and
30       eval'ed in another place.  The caller level should be the number of
31       stack levels between where the heredoc was created and where it is
32       eval'ed.
33
34        sub example {
35          return <<END_HEREIS
36            code
37       END_HEREIS
38        }
39
40        eval eval_line_numbers(1, example())
41

LICENSE

43       Copyright (C) 2009 David Muir Sharnoff.  Copyright (C) 2013 Google,
44       Inc.
45
46       This package may be used and redistributed under the terms of either
47       the Artistic 2.0 or LGPL 2.1 license.
48
49
50
51perl v5.32.0                      2020-07-28              Eval::LineNumbers(3)
Impressum