| 1 |
NAME |
| 2 |
|
| 3 |
Eval::LineNumbers - Add line numbers to heredoc blocks that contain |
| 4 |
perl source code |
| 5 |
|
| 6 |
VERSION |
| 7 |
|
| 8 |
version 0.35 |
| 9 |
|
| 10 |
SYNOPSIS |
| 11 |
|
| 12 |
use Eval::LineNumbers qw(eval_line_numbers); |
| 13 |
|
| 14 |
eval eval_line_numbers(<<END_HEREIS); |
| 15 |
code |
| 16 |
END_HEREIS |
| 17 |
|
| 18 |
eval eval_line_numbers($caller_level, $code) |
| 19 |
|
| 20 |
DESCRIPTION |
| 21 |
|
| 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 |
|
| 32 |
The second form of eval_line_numbers where a caller-level is provided |
| 33 |
is for the situation where the code is generated in one place and |
| 34 |
eval'ed in another place. The caller level should be the number of |
| 35 |
stack levels between where the heredoc was created and where it is |
| 36 |
eval'ed. |
| 37 |
|
| 38 |
sub example { |
| 39 |
return <<END_HEREIS |
| 40 |
code |
| 41 |
END_HEREIS |
| 42 |
} |
| 43 |
|
| 44 |
eval eval_line_numbers(1, example()) |
| 45 |
|
| 46 |
FUNCTIONS |
| 47 |
|
| 48 |
All functions are exportable on request, but not by default. |
| 49 |
|
| 50 |
eval_line_numbers |
| 51 |
|
| 52 |
eval eval_line_numbers($code); |
| 53 |
eval eval_line_numbers($caller_level, $code); |
| 54 |
|
| 55 |
eval_line_numbers_offset |
| 56 |
|
| 57 |
eval_line_numbers_offset $offset; |
| 58 |
|
| 59 |
Sets the offset, which is by default 1. The offset is file scoped. This |
| 60 |
is useful if you want to pass a string without a heredoc. For example: |
| 61 |
|
| 62 |
eval_line_numbers_offset 0; |
| 63 |
eval eval_line_numbers q{ |
| 64 |
die "here"; |
| 65 |
}; |
| 66 |
|
| 67 |
AUTHOR |
| 68 |
|
| 69 |
Original author: David Muir Sharnoff |
| 70 |
|
| 71 |
Current maintainer: Graham Ollis <[email protected]> |
| 72 |
|
| 73 |
Contributors: |
| 74 |
|
| 75 |
Olivier Mengué (DOLMEN) |
| 76 |
|
| 77 |
David Steinbrunner (dsteinbrunner) |
| 78 |
|
| 79 |
Alexey Ugnichev (thaewrapt) |
| 80 |
|
| 81 |
COPYRIGHT AND LICENSE |
| 82 |
|
| 83 |
This software is Copyright (c) 2009-2021 by David Muir Sharnoff. |
| 84 |
|
| 85 |
This is free software, licensed under: |
| 86 |
|
| 87 |
The GNU Lesser General Public License, Version 2.1, February 1999 |
| 88 |
|