The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

multidimensional - disables multidmensional array emulation

VERSION

version 0.001

SYNOPSIS

    no multidimensional;

    $hash{1, 2};                # dies
    $hash{join($;, 1, 2)};      # also dies

DESCRIPTION

Perl's multidimensional array emultaion 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 $ sigil instead of @.

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

METHODS

unimport

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

import

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

CAVEAT

Because of the way the module operates (by checking the optree), it also catches explicit use of join($;, ...) in a hash subscript. If you need to do this, either enable multidimensional hash emulation for just that scope or use one of the following workarounds:

    my $key = join($;, 1, 2);
    $hash{$key};

    my $sep = $;;
    $hash{join($sep, 1, 2)};

    $hash{join(my $sep = $;, 1, 2)};

SEE ALSO

"$;" in perlvar, B::Hooks::OP::Check.

AUTHOR

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

COPYRIGHT AND LICENSE

This software is copyright (c) 2010 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.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 86:

Non-ASCII character seen before =encoding in 'Mannsåker'. Assuming UTF-8