File tree Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,40 @@ None expected.
48
48
49
49
## Examples
50
50
51
- None. See above.
51
+ Imagine this module:
52
+
53
+ ``` perl
54
+ package Demo1 ;
55
+ use feature ' module_true' ;
56
+
57
+ sub import {
58
+ warn " You imported a module!\n " ;
59
+ }
60
+ ```
61
+
62
+ When loaded by ` require ` or ` use ` anywhere in perl, this would import
63
+ successfully, despite the lack of a true value at the end.
64
+
65
+ This module shows an (almost certainly never useful) way to croak anyway:
66
+
67
+ ``` perl
68
+ package Demo2 ;
69
+ use feature ' module_true' ;
70
+
71
+ return 1 if $main::test_1 ;
72
+ return 0 if $main::test_2 ;
73
+
74
+ {
75
+ no feature ' module_true' ;
76
+ return 0 if $main::test_3 ;
77
+ }
78
+ ```
79
+
80
+ In this example, the only case in which requiring Demo2 would fail is if
81
+ ` $main::test_3 ` was true. The previous ` return 0 if $main::test_2 ` would still
82
+ be within the scope of the ` module_true ` feature, so the return value would be
83
+ ignored. When ` 0 ` is returned outside the effect of ` module_true ` , though, the
84
+ old behavior of testing the return value is back in effect.
52
85
53
86
## Prototype Implementation
54
87
You can’t perform that action at this time.
0 commit comments