File: multidimensional.pm

package info (click to toggle)
libmultidimensional-perl 0.014-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 360 kB
  • sloc: perl: 201; makefile: 3
file content (88 lines) | stat: -rw-r--r-- 1,935 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package multidimensional;
# ABSTRACT: disables multidimensional array emulation
$multidimensional::VERSION = '0.014';
{ use 5.008001; }
use strict;
use warnings;

use if "$]" < 5.012, 'Lexical::SealRequireHints';
use B::Hooks::OP::Check 0.19;
use XSLoader;

XSLoader::load(
    __PACKAGE__,
    # we need to be careful not to touch $VERSION at compile time, otherwise
    # DynaLoader will assume it's set and check against it, which will cause
    # fail when being run in the checkout without dzil having set the actual
    # $VERSION
    exists $multidimensional::{VERSION} ? ${ $multidimensional::{VERSION} } : (),
);


sub unimport { $^H |= 0x20000; $^H{__PACKAGE__.'/disabled'} = 1 }


sub import { delete $^H{__PACKAGE__.'/disabled'} }


1;

__END__

=pod

=encoding UTF-8

=head1 NAME

multidimensional - disables multidimensional array emulation

=head1 VERSION

version 0.014

=head1 SYNOPSIS

    no multidimensional;

    $hash{1, 2};                # dies
    $hash{join($;, 1, 2)};      # doesn't die

=head1 DESCRIPTION

Perl's multidimensional array emulation stems from the days before the
language had references, but these days it mostly serves to bite you
when you typo a hash slice by using the C<$> sigil instead of C<@>.

This module lexically makes using multidimensional array emulation a
fatal error at compile time.

=head1 METHODS

=head2 unimport

Disables multidimensional array emulation for the remainder of the
scope being compiled.

=head2 import

Enables multidimensional array emulation for the remainder of the
scope being compiled;

=head1 SEE ALSO

L<perlvar/$;>,
L<B::Hooks::OP::Check>.

=head1 AUTHOR

Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2010 - 2016 by Dagfinn Ilmari Mannsåker.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut