← Index
NYTProf Performance Profile   « line view »
For t/bug-md-11.t
  Run on Fri Mar 8 13:27:24 2024
Reported on Fri Mar 8 13:30:23 2024

Filename/home/micha/.plenv/versions/5.38.2/lib/perl5/5.38.2/strict.pm
StatementsExecuted 0 statements in 0s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
136136128234µs234µsstrict::::importstrict::import
565629229µs229µsstrict::::unimportstrict::unimport
0000s0sstrict::::BEGINstrict::BEGIN
0000s0sstrict::::__ANON__[:31]strict::__ANON__[:31]
0000s0sstrict::::__ANON__[:37]strict::__ANON__[:37]
0000s0sstrict::::bitsstrict::bits
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package strict;
2
3$strict::VERSION = "1.12";
4
5my ( %bitmask, %explicit_bitmask );
6
7BEGIN {
8 # Verify that we're called correctly so that strictures will work.
9 # Can't use Carp, since Carp uses us!
10 # see also warnings.pm.
11 die sprintf "Incorrect use of pragma '%s' at %s line %d.\n", __PACKAGE__, +(caller)[1,2]
12 if __FILE__ !~ ( '(?x) \b '.__PACKAGE__.' \.pmc? \z' )
13 && __FILE__ =~ ( '(?x) \b (?i:'.__PACKAGE__.') \.pmc? \z' );
14
15 %bitmask = (
16 refs => 0x00000002,
17 subs => 0x00000200,
18 vars => 0x00000400,
19 );
20
21 %explicit_bitmask = (
22 refs => 0x00000020,
23 subs => 0x00000040,
24 vars => 0x00000080,
25 );
26
27 my $bits = 0;
28 $bits |= $_ for values %bitmask;
29
30 my $inline_all_bits = $bits;
31 *all_bits = sub () { $inline_all_bits };
32
33 $bits = 0;
34 $bits |= $_ for values %explicit_bitmask;
35
36 my $inline_all_explicit_bits = $bits;
37 *all_explicit_bits = sub () { $inline_all_explicit_bits };
38}
39
40sub bits {
41 my $bits = 0;
42 my @wrong;
43 foreach my $s (@_) {
44 if (exists $bitmask{$s}) {
45 $^H |= $explicit_bitmask{$s};
46
47 $bits |= $bitmask{$s};
48 }
49 else {
50 push @wrong, $s;
51 }
52 }
53 if (@wrong) {
54 require Carp;
55 Carp::croak("Unknown 'strict' tag(s) '@wrong'");
56 }
57 $bits;
58}
59
60
# spent 234µs within strict::import which was called 136 times, avg 2µs/call: # once (18µs+0s) by main::BEGIN@3 at line 3 of /home/micha/Projekt/spreadsheet-parsexlsx/t/bug-md-11.t # once (4µs+0s) by vars::BEGIN@8 at line 8 of vars.pm # once (4µs+0s) by base::BEGIN@4 at line 4 of base.pm # once (3µs+0s) by Symbol::BEGIN@167 at line 167 of Symbol.pm # once (2µs+0s) by Test2::EventFacet::Parent::BEGIN@2 at line 2 of Test2/EventFacet/Parent.pm # once (2µs+0s) by Test2::EventFacet::Plan::BEGIN@2 at line 2 of Test2/EventFacet/Plan.pm # once (2µs+0s) by Spreadsheet::ParseXLSX::Decryptor::BEGIN@3 at line 3 of /home/micha/Projekt/spreadsheet-parsexlsx/lib/Spreadsheet/ParseXLSX/Decryptor.pm # once (2µs+0s) by Test2::API::BEGIN@2 at line 2 of Test2/API.pm # once (2µs+0s) by List::Util::BEGIN@9 at line 9 of List/Util.pm # once (2µs+0s) by Test2::Util::BEGIN@2 at line 2 of Test2/Util.pm # once (2µs+0s) by Test2::Event::Pass::BEGIN@2 at line 2 of Test2/Event/Pass.pm # once (2µs+0s) by Test::Builder::Formatter::BEGIN@2 at line 2 of Test/Builder/Formatter.pm # once (2µs+0s) by Test::More::BEGIN@4 at line 4 of Test/More.pm # once (2µs+0s) by Test2::API::Context::BEGIN@2 at line 2 of Test2/API/Context.pm # once (2µs+0s) by Test2::API::Instance::BEGIN@2 at line 2 of Test2/API/Instance.pm # once (2µs+0s) by Test2::Event::Bail::BEGIN@2 at line 2 of Test2/Event/Bail.pm # once (2µs+0s) by Carp::BEGIN@4 at line 4 of Carp.pm # once (2µs+0s) by Config::BEGIN@9 at line 9 of Config.pm # once (2µs+0s) by Config::BEGIN@5 at line 5 of Config_heavy.pl # once (2µs+0s) by Test2::Formatter::BEGIN@2 at line 2 of Test2/Formatter.pm # once (2µs+0s) by Test2::Event::Note::BEGIN@2 at line 2 of Test2/Event/Note.pm # once (2µs+0s) by Exporter::BEGIN@3 at line 3 of Exporter.pm # once (2µs+0s) by Test2::API::Stack::BEGIN@2 at line 2 of Test2/API/Stack.pm # once (2µs+0s) by Test2::Event::BEGIN@2 at line 2 of Test2/Event.pm # once (2µs+0s) by Test2::Event::Subtest::BEGIN@2 at line 2 of Test2/Event/Subtest.pm # once (2µs+0s) by Test2::Event::Diag::BEGIN@2 at line 2 of Test2/Event/Diag.pm # once (2µs+0s) by Test2::Event::Plan::BEGIN@2 at line 2 of Test2/Event/Plan.pm # once (2µs+0s) by Archive::Zip::Archive::BEGIN@5 at line 5 of Archive/Zip/Archive.pm # once (2µs+0s) by Test2::Event::V2::BEGIN@2 at line 2 of Test2/Event/V2.pm # once (2µs+0s) by Test2::EventFacet::Hub::BEGIN@2 at line 2 of Test2/EventFacet/Hub.pm # once (2µs+0s) by Test2::Event::Waiting::BEGIN@2 at line 2 of Test2/Event/Waiting.pm # once (2µs+0s) by File::Temp::BEGIN@145 at line 145 of File/Temp.pm # once (2µs+0s) by Test2::Event::Ok::BEGIN@2 at line 2 of Test2/Event/Ok.pm # once (2µs+0s) by Test2::EventFacet::Info::BEGIN@2 at line 2 of Test2/EventFacet/Info.pm # once (2µs+0s) by Test2::Event::Exception::BEGIN@2 at line 2 of Test2/Event/Exception.pm # once (2µs+0s) by Test2::Event::Fail::BEGIN@2 at line 2 of Test2/Event/Fail.pm # once (2µs+0s) by Test::Builder::TodoDiag::BEGIN@2 at line 2 of Test/Builder/TodoDiag.pm # once (2µs+0s) by Test2::EventFacet::Trace::BEGIN@2 at line 2 of Test2/EventFacet/Trace.pm # once (2µs+0s) by OLE::Storage_Lite::PPS::Root::BEGIN@168 at line 168 of OLE/Storage_Lite.pm # once (2µs+0s) by Spreadsheet::ParseXLSX::BEGIN@3 at line 3 of /home/micha/Projekt/spreadsheet-parsexlsx/lib/Spreadsheet/ParseXLSX.pm # once (2µs+0s) by Test2::Util::ExternalMeta::BEGIN@2 at line 2 of Test2/Util/ExternalMeta.pm # once (2µs+0s) by Digest::Perl::MD5::BEGIN@2 at line 2 of Digest/Perl/MD5.pm # once (2µs+0s) by Spreadsheet::ParseExcel::Workbook::BEGIN@19 at line 19 of Spreadsheet/ParseExcel/Workbook.pm # once (2µs+0s) by Archive::Zip::DirectoryMember::BEGIN@3 at line 3 of Archive/Zip/DirectoryMember.pm # once (2µs+0s) by POSIX::BEGIN@2 at line 2 of POSIX.pm # once (2µs+0s) by Spreadsheet::ParseExcel::Font::BEGIN@19 at line 19 of Spreadsheet/ParseExcel/Font.pm # once (2µs+0s) by Time::HiRes::BEGIN@4 at line 4 of Time/HiRes.pm # once (2µs+0s) by File::Spec::BEGIN@3 at line 3 of File/Spec.pm # once (2µs+0s) by Test2::EventFacet::Amnesty::BEGIN@2 at line 2 of Test2/EventFacet/Amnesty.pm # once (2µs+0s) by Test2::EventFacet::Control::BEGIN@2 at line 2 of Test2/EventFacet/Control.pm # once (2µs+0s) by Spreadsheet::ParseExcel::BEGIN@17 at line 17 of Spreadsheet/ParseExcel.pm # once (2µs+0s) by Test::Builder::Module::BEGIN@3 at line 3 of Test/Builder/Module.pm # once (2µs+0s) by Crypt::Mode::ECB::BEGIN@5 at line 5 of Crypt/Mode/ECB.pm # once (2µs+0s) by Encode::MIME::Name::BEGIN@2 at line 2 of Encode/MIME/Name.pm # once (2µs+0s) by Archive::Zip::Member::BEGIN@5 at line 5 of Archive/Zip/Member.pm # once (2µs+0s) by Time::Local::BEGIN@3 at line 3 of Time/Local.pm # once (2µs+0s) by Archive::Zip::StringMember::BEGIN@3 at line 3 of Archive/Zip/StringMember.pm # once (2µs+0s) by Archive::Zip::ZipFileMember::BEGIN@3 at line 3 of Archive/Zip/ZipFileMember.pm # once (2µs+0s) by Test2::Event::Skip::BEGIN@2 at line 2 of Test2/Event/Skip.pm # once (2µs+0s) by Test2::EventFacet::About::BEGIN@2 at line 2 of Test2/EventFacet/About.pm # once (2µs+0s) by Archive::Zip::FileMember::BEGIN@3 at line 3 of Archive/Zip/FileMember.pm # once (2µs+0s) by Encode::BEGIN@5 at line 5 of Encode.pm # once (2µs+0s) by Test2::EventFacet::Error::BEGIN@2 at line 2 of Test2/EventFacet/Error.pm # once (2µs+0s) by parent::BEGIN@2 at line 2 of parent.pm # once (2µs+0s) by Exporter::Heavy::BEGIN@3 at line 3 of Exporter/Heavy.pm # once (2µs+0s) by File::Glob::BEGIN@3 at line 3 of File/Glob.pm # once (2µs+0s) by Encode::Encoding::BEGIN@4 at line 4 of Encode/Encoding.pm # once (2µs+0s) by Scalar::Util::BEGIN@9 at line 9 of Scalar/Util.pm # once (2µs+0s) by Archive::Zip::NewFileMember::BEGIN@3 at line 3 of Archive/Zip/NewFileMember.pm # once (2µs+0s) by Encode::Config::BEGIN@7 at line 7 of Encode/Config.pm # once (2µs+0s) by XML::Parser::BEGIN@11 at line 11 of XML/Parser.pm # once (2µs+0s) by Test2::Hub::Interceptor::BEGIN@2 at line 2 of Test2/Hub/Interceptor.pm # once (2µs+0s) by Test2::EventFacet::Assert::BEGIN@2 at line 2 of Test2/EventFacet/Assert.pm # once (2µs+0s) by Spreadsheet::ParseXLSX::Decryptor::Agile::BEGIN@3 at line 3 of /home/micha/Projekt/spreadsheet-parsexlsx/lib/Spreadsheet/ParseXLSX/Decryptor/Agile.pm # once (2µs+0s) by Spreadsheet::ParseXLSX::Cell::BEGIN@3 at line 3 of /home/micha/Projekt/spreadsheet-parsexlsx/lib/Spreadsheet/ParseXLSX/Cell.pm # once (2µs+0s) by File::Copy::BEGIN@11 at line 11 of File/Copy.pm # once (2µs+0s) by Encode::Alias::BEGIN@2 at line 2 of Encode/Alias.pm # once (2µs+0s) by IO::File::BEGIN@120 at line 120 of IO/File.pm # once (2µs+0s) by Compress::Raw::Zlib::BEGIN@8 at line 8 of Compress/Raw/Zlib.pm # once (2µs+0s) by Test2::Hub::BEGIN@2 at line 2 of Test2/Hub.pm # once (2µs+0s) by Spreadsheet::ParseXLSX::BEGIN@1 at line 1 of XML/Twig.pm # once (2µs+0s) by File::Find::BEGIN@3 at line 3 of File/Find.pm # once (2µs+0s) by FileHandle::BEGIN@4 at line 4 of FileHandle.pm # once (2µs+0s) by Test::Builder::BEGIN@4 at line 4 of Test/Builder.pm # once (2µs+0s) by Digest::base::BEGIN@3 at line 3 of Digest/base.pm # once (2µs+0s) by Test2::Util::HashBase::BEGIN@2 at line 2 of Test2/Util/HashBase.pm # once (2µs+0s) by overload::BEGIN@3 at line 3 of overload.pm # once (2µs+0s) by MIME::Base64::BEGIN@3 at line 3 of MIME/Base64.pm # once (2µs+0s) by Spreadsheet::ParseExcel::Worksheet::BEGIN@19 at line 19 of Spreadsheet/ParseExcel/Worksheet.pm # once (2µs+0s) by File::Temp::Dir::BEGIN@2602 at line 2602 of File/Temp.pm # once (2µs+0s) by Test2::EventFacet::Meta::BEGIN@2 at line 2 of Test2/EventFacet/Meta.pm # once (2µs+0s) by URI::BEGIN@3 at line 3 of URI.pm # once (2µs+0s) by Fcntl::BEGIN@58 at line 58 of Fcntl.pm # once (2µs+0s) by mro::BEGIN@10 at line 10 of mro.pm # once (2µs+0s) by JSON::PP::BEGIN@6 at line 6 of JSON/PP.pm # once (2µs+0s) by Test2::Util::Facets2Legacy::BEGIN@2 at line 2 of Test2/Util/Facets2Legacy.pm # once (2µs+0s) by Test2::EventFacet::BEGIN@2 at line 2 of Test2/EventFacet.pm # once (2µs+0s) by Test2::Hub::Subtest::BEGIN@2 at line 2 of Test2/Hub/Subtest.pm # once (2µs+0s) by OLE::Storage_Lite::PPS::File::BEGIN@713 at line 713 of OLE/Storage_Lite.pm # once (1µs+0s) by Digest::SHA::BEGIN@5 at line 5 of Digest/SHA.pm # once (1µs+0s) by URI::Escape::BEGIN@3 at line 3 of URI/Escape.pm # once (1µs+0s) by Archive::Zip::BEGIN@4 at line 4 of Archive/Zip.pm # once (1µs+0s) by Test2::Formatter::TAP::BEGIN@2 at line 2 of Test2/Formatter/TAP.pm # once (1µs+0s) by Crypt::RC4::BEGIN@15 at line 15 of Crypt/RC4.pm # once (1µs+0s) by File::Find::BEGIN@13 at line 13 of File/Find.pm # once (1µs+0s) by constant::BEGIN@3 at line 3 of constant.pm # once (1µs+0s) by Graphics::ColorUtils::BEGIN@5 at line 5 of Graphics/ColorUtils.pm # once (1µs+0s) by Spreadsheet::ParseXLSX::Decryptor::Standard::BEGIN@3 at line 3 of /home/micha/Projekt/spreadsheet-parsexlsx/lib/Spreadsheet/ParseXLSX/Decryptor/Standard.pm # once (1µs+0s) by bytes::BEGIN@3 at line 3 of bytes.pm # once (1µs+0s) by File::Basename::BEGIN@50 at line 50 of File/Basename.pm # once (1µs+0s) by File::Path::BEGIN@4 at line 4 of File/Path.pm # once (1µs+0s) by Spreadsheet::ParseExcel::FmtDefault::BEGIN@19 at line 19 of Spreadsheet/ParseExcel/FmtDefault.pm # once (1µs+0s) by IO::Seekable::BEGIN@99 at line 99 of IO/Seekable.pm # once (1µs+0s) by utf8::BEGIN@3 at line 3 of utf8.pm # once (1µs+0s) by Test2::Hub::Interceptor::Terminator::BEGIN@2 at line 2 of Test2/Hub/Interceptor/Terminator.pm # once (1µs+0s) by IO::Handle::BEGIN@272 at line 272 of IO/Handle.pm # once (1µs+0s) by OLE::Storage_Lite::PPS::Dir::BEGIN@801 at line 801 of OLE/Storage_Lite.pm # once (1µs+0s) by Errno::BEGIN@9 at line 9 of Errno.pm # once (1µs+0s) by builtin::BEGIN@3 at line 3 of builtin.pm # once (1µs+0s) by XML::Parser::Expat::BEGIN@3 at line 3 of XML/Parser/Expat.pm # once (1µs+0s) by Spreadsheet::ParseExcel::Format::BEGIN@19 at line 19 of Spreadsheet/ParseExcel/Format.pm # once (1µs+0s) by Cwd::BEGIN@2 at line 2 of Cwd.pm # once (1µs+0s) by Test2::Util::Trace::BEGIN@5 at line 5 of Test2/Util/Trace.pm # once (1µs+0s) by IO::BEGIN@7 at line 7 of IO.pm # once (1µs+0s) by Symbol::BEGIN@3 at line 3 of Symbol.pm # once (1µs+0s) by JSON::PP::Boolean::BEGIN@3 at line 3 of JSON/PP/Boolean.pm # once (1µs+0s) by JSON::BEGIN@4 at line 4 of JSON.pm # once (1µs+0s) by JSON::PP::IncrParser::BEGIN@1485 at line 1485 of JSON/PP.pm # once (1µs+0s) by File::Spec::Unix::BEGIN@3 at line 3 of File/Spec/Unix.pm # once (1µs+0s) by OLE::Storage_Lite::PPS::BEGIN@12 at line 12 of OLE/Storage_Lite.pm # once (1µs+0s) by Spreadsheet::ParseExcel::Cell::BEGIN@19 at line 19 of Spreadsheet/ParseExcel/Cell.pm # once (1µs+0s) by CryptX::BEGIN@3 at line 3 of CryptX.pm # once (1µs+0s) by Crypt::Mode::CBC::BEGIN@5 at line 5 of Crypt/Mode/CBC.pm # once (1µs+0s) by Spreadsheet::ParseExcel::Utility::BEGIN@19 at line 19 of Spreadsheet/ParseExcel/Utility.pm # once (1µs+0s) by OLE::Storage_Lite::BEGIN@828 at line 828 of OLE/Storage_Lite.pm # once (1µs+0s) by Crypt::Cipher::BEGIN@3 at line 3 of Crypt/Cipher.pm
sub import {
61 shift;
62 $^H |= @_ ? &bits : all_bits | all_explicit_bits;
63}
64
65
# spent 229µs within strict::unimport which was called 56 times, avg 4µs/call: # once (15µs+0s) by Test::Builder::BEGIN@120 at line 120 of Test/Builder.pm # once (6µs+0s) by XML::Parser::Expat::BEGIN@460 at line 460 of XML/Parser/Expat.pm # once (6µs+0s) by Symbol::BEGIN@103 at line 103 of Symbol.pm # once (5µs+0s) by Carp::BEGIN@730 at line 730 of Carp.pm # once (5µs+0s) by Test2::API::Instance::BEGIN@62 at line 62 of Test2/API/Instance.pm # once (5µs+0s) by Time::HiRes::BEGIN@70 at line 70 of Time/HiRes.pm # once (5µs+0s) by Carp::BEGIN@256 at line 256 of Carp.pm # once (5µs+0s) by Carp::BEGIN@188 at line 188 of Carp.pm # once (4µs+0s) by Test2::Util::HashBase::BEGIN@94 at line 94 of Test2/Util/HashBase.pm # once (4µs+0s) by Cwd::BEGIN@644 at line 644 of Cwd.pm # once (4µs+0s) by XML::Twig::BEGIN@1327 at line 1327 of XML/Twig.pm # once (4µs+0s) by List::Util::BEGIN@35 at line 35 of List/Util.pm # once (4µs+0s) by IO::Handle::BEGIN@617 at line 617 of IO/Handle.pm # once (4µs+0s) by Test::More::BEGIN@209 at line 209 of Test/More.pm # once (4µs+0s) by Test::Builder::BEGIN@1518 at line 1518 of Test/Builder.pm # once (4µs+0s) by XML::Twig::BEGIN@3229 at line 3229 of XML/Twig.pm # once (4µs+0s) by JSON::Backend::PP::BEGIN@342 at line 342 of JSON.pm # once (4µs+0s) by URI::BEGIN@180 at line 180 of URI.pm # once (4µs+0s) by Test::Builder::BEGIN@1251 at line 1251 of Test/Builder.pm # once (4µs+0s) by constant::BEGIN@40 at line 40 of constant.pm # once (4µs+0s) by XML::Twig::BEGIN@3587 at line 3587 of XML/Twig.pm # once (4µs+0s) by Exporter::BEGIN@4 at line 4 of Exporter.pm # once (4µs+0s) by File::Path::BEGIN@29 at line 29 of File/Path.pm # once (4µs+0s) by Test2::EventFacet::Meta::BEGIN@30 at line 30 of Test2/EventFacet/Meta.pm # once (4µs+0s) by Symbol::BEGIN@137 at line 137 of Symbol.pm # once (4µs+0s) by Config::BEGIN@47 at line 47 of Config.pm # once (4µs+0s) by parent::BEGIN@21 at line 21 of parent.pm # once (4µs+0s) by File::Spec::Unix::BEGIN@167 at line 167 of File/Spec/Unix.pm # once (4µs+0s) by Compress::Raw::Zlib::BEGIN@121 at line 121 of Compress/Raw/Zlib.pm # once (4µs+0s) by Test2::Util::HashBase::BEGIN@37 at line 37 of Test2/Util/HashBase.pm # once (4µs+0s) by File::Temp::BEGIN@240 at line 240 of File/Temp.pm # once (4µs+0s) by Exporter::Heavy::BEGIN@4 at line 4 of Exporter/Heavy.pm # once (4µs+0s) by XML::Twig::BEGIN@4159 at line 4159 of XML/Twig.pm # once (4µs+0s) by XML::Twig::BEGIN@3852 at line 3852 of XML/Twig.pm # once (4µs+0s) by Symbol::BEGIN@156 at line 156 of Symbol.pm # once (4µs+0s) by Test::Builder::BEGIN@61 at line 61 of Test/Builder.pm # once (4µs+0s) by Test::Builder::BEGIN@1539 at line 1539 of Test/Builder.pm # once (4µs+0s) by Test::Builder::BEGIN@102 at line 102 of Test/Builder.pm # once (4µs+0s) by FileHandle::BEGIN@46 at line 46 of FileHandle.pm # once (4µs+0s) by Carp::BEGIN@751 at line 751 of Carp.pm # once (4µs+0s) by Test::Builder::BEGIN@116 at line 116 of Test/Builder.pm # once (4µs+0s) by XML::Twig::BEGIN@3619 at line 3619 of XML/Twig.pm # once (3µs+0s) by constant::BEGIN@65 at line 65 of constant.pm # once (3µs+0s) by XML::Twig::BEGIN@3648 at line 3648 of XML/Twig.pm # once (3µs+0s) by Test::Builder::BEGIN@1556 at line 1556 of Test/Builder.pm # once (3µs+0s) by constant::BEGIN@141 at line 141 of constant.pm # once (3µs+0s) by overload::BEGIN@4 at line 4 of overload.pm # once (3µs+0s) by File::Temp::BEGIN@270 at line 270 of File/Temp.pm # once (3µs+0s) by constant::BEGIN@90 at line 90 of constant.pm # once (3µs+0s) by XML::Twig::BEGIN@4246 at line 4246 of XML/Twig.pm # once (3µs+0s) by XML::Twig::BEGIN@4175 at line 4175 of XML/Twig.pm # once (3µs+0s) by XML::Twig::BEGIN@4211 at line 4211 of XML/Twig.pm # once (3µs+0s) by Spreadsheet::ParseExcel::BEGIN@2628 at line 2628 of Spreadsheet/ParseExcel.pm # once (3µs+0s) by POSIX::BEGIN@225 at line 225 of POSIX.pm # once (2µs+0s) by XML::Twig::BEGIN@4181 at line 4181 of XML/Twig.pm # once (2µs+0s) by File::Glob::BEGIN@54 at line 54 of File/Glob.pm
sub unimport {
66 shift;
67
68 if (@_) {
69 $^H &= ~&bits;
70 }
71 else {
72 $^H &= ~all_bits;
73 $^H |= all_explicit_bits;
74 }
75}
76
771;
78__END__
79
80=head1 NAME
81
82strict - Perl pragma to restrict unsafe constructs
83
84=head1 SYNOPSIS
85
86 use strict;
87
88 use strict "vars";
89 use strict "refs";
90 use strict "subs";
91
92 use strict;
93 no strict "vars";
94
95=head1 DESCRIPTION
96
97The C<strict> pragma disables certain Perl expressions that could behave
98unexpectedly or are difficult to debug, turning them into errors. The
99effect of this pragma is limited to the current file or scope block.
100
101If no import list is supplied, all possible restrictions are assumed.
102(This is the safest mode to operate in, but is sometimes too strict for
103casual programming.) Currently, there are three possible things to be
104strict about: "subs", "vars", and "refs".
105
106=over 6
107
108=item C<strict refs>
109
110This generates a runtime error if you
111use symbolic references (see L<perlref>).
112
113 use strict 'refs';
114 $ref = \$foo;
115 print $$ref; # ok
116 $ref = "foo";
117 print $$ref; # runtime error; normally ok
118 $file = "STDOUT";
119 print $file "Hi!"; # error; note: no comma after $file
120
121There is one exception to this rule:
122
123 $bar = \&{'foo'};
124 &$bar;
125
126is allowed so that C<goto &$AUTOLOAD> would not break under stricture.
127
128
129=item C<strict vars>
130
131This generates a compile-time error if you access a variable that was
132neither explicitly declared (using any of C<my>, C<our>, C<state>, or C<use
133vars>) nor fully qualified. (Because this is to avoid variable suicide
134problems and subtle dynamic scoping issues, a merely C<local> variable isn't
135good enough.) See L<perlfunc/my>, L<perlfunc/our>, L<perlfunc/state>,
136L<perlfunc/local>, and L<vars>.
137
138 use strict 'vars';
139 $X::foo = 1; # ok, fully qualified
140 my $foo = 10; # ok, my() var
141 local $baz = 9; # blows up, $baz not declared before
142
143 package Cinna;
144 our $bar; # Declares $bar in current package
145 $bar = 'HgS'; # ok, global declared via pragma
146
147The local() generated a compile-time error because you just touched a global
148name without fully qualifying it.
149
150Because of their special use by sort(), the variables $a and $b are
151exempted from this check.
152
153=item C<strict subs>
154
155This disables the poetry optimization, generating a compile-time error if
156you try to use a bareword identifier that's not a subroutine, unless it
157is a simple identifier (no colons) and that it appears in curly braces,
158on the left hand side of the C<< => >> symbol, or has the unary minus
159operator applied to it.
160
161 use strict 'subs';
162 $SIG{PIPE} = Plumber; # blows up
163 $SIG{PIPE} = "Plumber"; # fine: quoted string is always ok
164 $SIG{PIPE} = \&Plumber; # preferred form
165
166=back
167
168See L<perlmodlib/Pragmatic Modules>.
169
170=head1 HISTORY
171
172C<strict 'subs'>, with Perl 5.6.1, erroneously permitted to use an unquoted
173compound identifier (e.g. C<Foo::Bar>) as a hash key (before C<< => >> or
174inside curlies), but without forcing it always to a literal string.
175
176Starting with Perl 5.8.1 strict is strict about its restrictions:
177if unknown restrictions are used, the strict pragma will abort with
178
179 Unknown 'strict' tag(s) '...'
180
181As of version 1.04 (Perl 5.10), strict verifies that it is used as
182"strict" to avoid the dreaded Strict trap on case insensitive file
183systems.
184
185=cut