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

VERSION

10       version 0.35
11

SYNOPSIS

13        use Eval::LineNumbers qw(eval_line_numbers);
14
15        eval eval_line_numbers(<<END_HEREIS);
16          code
17        END_HEREIS
18
19        eval eval_line_numbers($caller_level, $code)
20

DESCRIPTION

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

FUNCTIONS

46       All functions are exportable on request, but not by default.
47
48   eval_line_numbers
49        eval eval_line_numbers($code);
50        eval eval_line_numbers($caller_level, $code);
51
52   eval_line_numbers_offset
53        eval_line_numbers_offset $offset;
54
55       Sets the offset, which is by default 1.  The offset is file scoped.
56       This is useful if you want to pass a string without a heredoc.  For
57       example:
58
59        eval_line_numbers_offset 0;
60        eval eval_line_numbers q{
61          die "here";
62        };
63

AUTHOR

65       Original author: David Muir Sharnoff
66
67       Current maintainer: Graham Ollis <plicease@cpan.org>
68
69       Contributors:
70
71       Olivier Mengué (DOLMEN)
72
73       David Steinbrunner (dsteinbrunner)
74
75       Alexey Ugnichev (thaewrapt)
76
78       This software is Copyright (c) 2009-2021 by David Muir Sharnoff.
79
80       This is free software, licensed under:
81
82         The GNU Lesser General Public License, Version 2.1, February 1999
83
84
85
86perl v5.36.0                      2023-01-20              Eval::LineNumbers(3)
Impressum