Readers: 7
1
2
3
4
5
6
7
8
9
{
...
'Sisimai::Address' => sub {
my $Field = Sisimai::Address->find($HeaderLine);
my @Addrs = $Field->@*;
my $NumAddrs = @Addrs;
say "Sisimai::Address got $NumAddrs" unless $NumAddrs == 5_000;
},
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use v5.24;
use warnings;
my %hash = (
do {
my $key = 'AAA';
$key,
sub {
say $key;
};
},
do {
my $key = 'BBB';
$key,
sub {
say $key;
};
},
);
$hash{'AAA'}->();
$hash{'BBB'}->();
1 2 3 4 5 6 7 8 9 10 11 12 13
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my %hash = ( do { my $key = 'AAA'; $key, sub { print "$key\n"; }; }, do { my $key = 'BBB'; $key, sub { print "$key\n"; }; }, ); print Dumper(\%hash);
my %hash = ("a" => 10, "b" => 10);
2025-07-07T14:30:16 hlubenow1. Keine Ahnung, was ihr da mit dem "do" macht.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
use v5.24; use warnings; use Benchmark qw(cmpthese); sub find_key { my ($hash, $current_sub) = @_; for my $key ( keys $hash->%* ) { return $key if $hash->{$key} == $current_sub; } return "not found"; } my $subs; cmpthese( 2, $subs = { AAA => sub { say ''; say 'aaa'; say find_key($subs, __SUB__) }, BBB => sub { say ''; say 'bbb'; say find_key($subs, __SUB__) }, } );