Debian Codegraph @

README

raw
1 NAME
2
3 goto::file - Stop parsing the current file and move on to a different
4 one.
5
6 DESCRIPTION
7
8 It is rare, but there are times where you want to swap out the
9 currently compiling file for a different one. This module does that.
10 From the point you use the module perl will be parsing the new file
11 instead of the original.
12
13 WHY?!
14
15 This was created specifically for Test2::Harness which can preload
16 modules and fork to run each test. The problem was that using do to
17 execute the test files post-fork was resuling in extra frames in the
18 stack trace... in other words there are a lot of tests that assume the
19 test file is the bottom of the stack. This happens all the time,
20 specially if stack traces need to be verified.
21
22 This module allows Test2::Harness to swap out the main script for the
23 new file without adding a stack frame.
24
25 SYNOPSIS
26
27 Plain and simple:
28
29 #!/usr/bin/perl
30
31 use goto::file 'some_file.pl';
32
33 die "This will never be seen!";
34
35 __DATA__
36
37 This data will not be seen by <DATA>
38
39 More useful:
40
41 #!/usr/bin/perl
42
43 BEGIN {
44 my $file = should_switch_files();
45
46 if ($file) {
47 print "about to switch to file '$file'\n";
48 require goto::file;
49 goto::file->import($file);
50 }
51 }
52
53 print "Did not go to a file\n";
54
55 Another thing you can do:
56
57 use goto::file [
58 'print "Hi!\n";',
59 "exit 0",
60 ];
61
62 die "Will not get here";
63
64 NOTES
65
66 __DATA__ and <DATA>
67
68 This module does its very best to make sure the data you get from
69 <DATA> comes from the NEW file, and not the old. At the moment there
70 are no known failure cases, but there could be some.
71
72 IMPLEMENTATION DETAILS
73
74 This is a source filter. The source filter simply disgards the lines
75 from the original file and instead feeds perl lines from the new file.
76 There is also a small source injection at the start that sets up <DATA>
77 and makes sure line numbers and file name are all correct.
78
79 SOURCE
80
81 The source code repository for goto-file can be found at
82 http://github.com/exodist/goto-file/.
83
84 MAINTAINERS
85
86 Chad Granum <[email protected]>
87
88 AUTHORS
89
90 Chad Granum <[email protected]>
91
92 COPYRIGHT
93
94 Copyright 2017 Chad Granum <[email protected]>.
95
96 This program is free software; you can redistribute it and/or modify it
97 under the same terms as Perl itself.
98
99 See http://dev.perl.org/licenses/
100