#!./perl -w
BEGIN {
chdir 't' if -d 't';
}
use strict;
# Two hashes one will all keys 8-bit possible (initially), other
# with a utf8 requiring key from the outset.
"\x7f" => 0x7f,
);
"\x7f" => 0x7f,
"\x{1ff}" => 0x1ff,
);
# Check that we can find the 8-bit things by various litterals
# Now try same thing with variables forced into various forms.
foreach ("\x7f","\xff")
{
my $a = $_; # Force a copy
}
# Check we have not got an spurious extra keys
# Now add a utf8 key to the 8-bit hash
# Check we have not got an spurious extra keys
foreach ("\x7f","\xff","\x{1ff}")
{
my $a = $_;
}
# and remove utf8 from the other hash
foreach ("\x7f","\xff")
{
my $a = $_;
}
{
print "# Unicode hash keys and \\w\n";
# This is not really a regex test but regexes bring
# out the issue nicely.
use strict;
while (@u) {
my $l = 0 + /^\w+$/;
my $r = 0 + $u{$_} =~ /^\w+$/;
}
my $more;
do {
$more = 0;
# Want to do this direct, rather than copying to a temporary variable
# The first time each will return key and value at the start of the hash.
# each will return () after we've done the last pair. $more won't get
# set then, and the do will exit.
$more = 1;
my $l = 0 + /^\w+$/;
my $r = 0 + $u{$_} =~ /^\w+$/;
}
for (%u) {
my $l = 0 + /^\w+$/;
my $r = 0 + $u{$_} =~ /^\w+$/;
}
pop @u;
undef %u;
}
}
{
my $l = 0 + /^\w+$/;
my $r = 0 + $bytes_first{$_} =~ /^\w+$/;
}
my $l = 0 + /^\w+$/;
my $r = 0 + $bytes_first{$_} =~ /^\w+$/;
}
my $l = 0 + /^\w+$/;
my $r = 0 + $utf8_first{$_} =~ /^\w+$/;
}
my $l = 0 + /^\w+$/;
my $r = 0 + $utf8_first{$_} =~ /^\w+$/;
}
}
{
# See if utf8 barewords work [perl #22969]
use utf8;
my %hash = (тест => 123);
%hash = (тест => 123);
}