Add Rafael's example user pragma, and convert his demo to a test.
[p5sagit/p5-mst-13.2.git] / t / lib / mypragma.pm
1 =head1 NAME
2
3 mypragma - an example of a user pragma
4
5 =head1 SYNOPSIS
6
7 In your code
8
9     use mypragma; # Enable the pragma
10     
11     mypragma::in_effect() # returns true; pragma is enabled
12
13     no mypragma;
14     
15     mypragma::in_effect() # returns false; pragma is not enabled
16
17 =head1 DESCRIPTION
18
19 An example of how to write a pragma.
20
21 =head1 AUTHOR
22
23 Rafael Garcia-Suarez
24
25 =cut
26
27 package mypragma;
28
29 use strict;
30 use warnings;
31
32 sub import {
33     $^H{mypragma} = 1;
34     $^H |= 0x00020000;
35 }
36
37 sub unimport {
38     $^H{mypragma} = 0;
39 }
40
41 sub in_effect {
42     my $hinthash = (caller(0))[10];
43     return $hinthash->{mypragma};
44 }
45
46 1;