1Long::Jump(3)         User Contributed Perl Documentation        Long::Jump(3)
2
3
4

NAME

6       Long::Jump - Mechanism for returning to a specific point from a deeply
7       nested stack.
8

DESCRIPTION

10       This module essentially provides a multi-level return. You can mark a
11       spot with "setjump()" and then unwind the stack back to that point from
12       any nested stack frame by name using "longjump()". You can also provide
13       a list of return values.
14
15       This is not quite a match for C's long jump, but it is "close enough".
16       It is safer than C's jump in that it only lets you escape frames by
17       going up the stack, you cannot jump in other ways.
18

SYNOPSIS

20           use Long::Jump qw/setjump longjump/;
21
22           my $out = setjump foo => sub {
23               bar();
24               ...; # Will never get here
25           };
26           is($out, [qw/x y z/], "Got results of the long jump");
27
28           $out = setjump foo => sub {
29               print "Not calling longjump";
30           };
31           is($out, undef, "longjump was not called so we got an undef response");
32
33           sub bar {
34               baz();
35               return 'bar'; # Will never get here
36           }
37
38           sub baz {
39               bat();
40               return 'baz'; # Will never get here
41           }
42
43           sub bat {
44               my @out = qw/x y z/;
45               longjump foo => @out;
46
47               return 'bat'; # Will never get here
48           }
49

EXPORTS

51       $out = setjump($NAME, sub { ... })
52       $out = setjump $NAME, sub { ... }
53       $out = setjump($NAME => sub { ... })
54       $out = setjump $NAME => sub { ... }
55           Set a named point to which you will return when calling
56           "longjump()". $out will be "undef" if "longjump()" was not called.
57           $out will be an arrayref if "longjump()" was called. The $out
58           arrayref will be empty, but present if "longjump()" is called
59           without any return values.
60
61           The return value will always be false if "longjump" was not called,
62           and will always be true if it was called.
63
64           You cannot nest multiple jump points with the same name, but you
65           can nest multiple jump points if they have unqiue names.
66           "longjump()" will always jump to the correct name.
67
68       longjump($NAME)
69       longjump $NAME
70       longjump($NAME, @RETURN_LIST)
71       longjump($NAME => @RETURN_LIST)
72       longjump $NAME => @RETURN_LIST
73           Jump to the named point, optionally with values to return. This
74           will throw exceptions if you use an invalid $NAME, which includes
75           the case of calling it without a set jump point.
76

SOURCE

78       The source code repository for Long-Jump can be found at
79       https://github.com/exodist/Long-Jump/.
80

MAINTAINERS

82       Chad Granum <exodist@cpan.org>
83

AUTHORS

85       Chad Granum <exodist@cpan.org>
86
88       Copyright 2018 Chad Granum <exodist7@gmail.com>.
89
90       This program is free software; you can redistribute it and/or modify it
91       under the same terms as Perl itself.
92
93       See http://dev.perl.org/licenses/
94
95
96
97perl v5.32.0                      2020-07-28                     Long::Jump(3)
Impressum