1Modern::Perl(3)       User Contributed Perl Documentation      Modern::Perl(3)
2
3
4

NAME

6       Modern::Perl - enable all of the features of Modern Perl with one
7       import
8

VERSION

10       version 1.20200211
11

SYNOPSIS

13       Modern Perl programs use several modules to enable additional features
14       of Perl and of the CPAN.  Instead of copying and pasting all of these
15       "use" lines, instead write only one:
16
17           use Modern::Perl;
18
19       This enables the strict and warnings pragmas, as well as all of the
20       features available in Perl 5.10. It also enables C3 method resolution
21       order as documented in "perldoc mro" and loads IO::File and IO::Handle
22       so that you may call methods on filehandles. In the future, it may
23       include additional core modules and pragmas (but is unlikely to include
24       non-core features).
25
26       Because so much of this module's behavior uses lexically scoped
27       pragmas, you may disable these pragmas within an inner scope with:
28
29           no Modern::Perl;
30
31       See
32       <http://www.modernperlbooks.com/mt/2009/01/toward-a-modernperl.html>
33       for more information, <http://www.modernperlbooks.com/> for further
34       discussion of Modern Perl and its implications, and
35       <http://onyxneon.com/books/modern_perl/index.html> for a freely-
36       downloadable Modern Perl tutorial.
37
38   CLI Usage
39       As of Modern::Perl 2019, you may also enable this pragma from the
40       command line:
41
42           $ perl -Modern::Perl -e 'say "Take that, awk!"'
43
44       You may also enable year-specific features:
45
46           $ perl -Modern::Perl=2020 -e 'say "Looking forward to Perl 5.30!"'
47
48   Wrapping Modern::Perl
49       If you want to wrap Modern::Perl in your own "import()" method, you can
50       do so to add additional pragmas or features, such as the use of
51       Try::Tiny. Please note that, if you do so, you will not automatically
52       enable C3 method resolution in the calling scope. This is due to how
53       the mro pragma works. In your custom "import()" method, you will need
54       to write code such as:
55
56           mro::set_mro( scalar caller(), 'c3' );
57
58   Forward Compatibility
59       For forward compatibility, I recommend you specify a string containing
60       a year value as the single optional import tag. For example:
61
62           use Modern::Perl '2009';
63           use Modern::Perl '2010';
64
65       ... both enable 5.10 features, while:
66
67           use Modern::Perl '2011';
68
69       ... enables 5.12 features:
70
71           use Modern::Perl '2012';
72
73       ... enables 5.14 features:
74
75           use Modern::Perl '2013';
76
77       ... enables 5.16 features, and:
78
79           use Modern::Perl '2014';
80
81       ... enables 5.18 features, and:
82
83           use Modern::Perl '2015';
84
85       ... enables 5.20 features, and:
86
87           use Modern::Perl '2016';
88
89       ... enables 5.24 features, and:
90
91           use Modern::Perl '2017';
92
93       ... enables 5.24 features, and:
94
95           use Modern::Perl '2018';
96
97       ... enables 5.26 features.
98
99       Obviously you cannot use newer features on earlier versions. Perl will
100       throw the appropriate exception if you try.
101

AUTHOR

103       chromatic, "<chromatic at wgz.org>"
104

BUGS

106       None known.
107
108       Please report any bugs or feature requests to "bug-modern-perl at
109       rt.cpan.org", or through the web interface at
110       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Modern-Perl>.  I will
111       be notified, and then you'll automatically be notified of progress on
112       your bug as I make changes.
113

SUPPORT

115       You can find documentation for this module with the perldoc command.
116
117           perldoc Modern::Perl
118
119       You can also look for information at:
120
121       •   RT: CPAN's request tracker
122
123           <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Modern-Perl>
124
125       •   AnnoCPAN: Annotated CPAN documentation
126
127           <http://annocpan.org/dist/Modern-Perl>
128
129       •   CPAN Ratings
130
131           <http://cpanratings.perl.org/d/Modern-Perl>
132
133       •   Search CPAN
134
135           <http://search.cpan.org/dist/Modern-Perl/>
136

ACKNOWLEDGEMENTS

138       Damian Conway (inspiration from Toolkit), Florian Ragwitz
139       (B::Hooks::Parser, so I didn't have to write it myself), chocolateboy
140       (for suggesting that I don't even need B::Hooks::Parser), Damien Learns
141       Perl, David Moreno, Evan Carroll, Elliot Shank, Andreas König, Father
142       Chrysostomos, Gryphon Shafer, and Norbert E. Grüner for reporting bugs,
143       filing patches, and requesting features.
144

AUTHOR

146       chromatic
147
149       This software is copyright (c) 2018 by chromatic@wgz.org.
150
151       This is free software; you can redistribute it and/or modify it under
152       the same terms as the Perl 5 programming language system itself.
153
154
155
156perl v5.32.1                      2021-01-27                   Modern::Perl(3)
Impressum