in reply to Re: Perl at Rosetta Code, with one particular example
in thread Perl at Rosetta Code, with one particular example

There are a few more with (missing) "g" modifier; and s/5/6/; anyway it gets above 1 s for me. OTOH (definitely not a one-liner though):

# Rate am_new # am_new 40.9/s -- am_new => sub { my ( @a, %h ); open my $fh, '<:raw', 'unixdict.txt' or die; while ( <$fh> ) { next unless length > 6; chomp; push @a, $_ if -1 != index $_, 'e'; next unless -1 != index $_, 'i'; my $key = tr/e/i/r; $h{ $key } = $_ unless exists $h{ $key } and $_ lt $h{ $key } } close $fh; my ( @ret, $key ); exists $h{ $key = tr/e/i/r } and $h{ $key } gt $_ and push @ret, sprintf "%30s %s\n", $_, $h{ $key } for @a; @ret },

And, e.g. for (some or all of) "e => a" (not "i") then "gt", "lt" should be swapped.

Replies are listed 'Best First'.
Re^3: Perl at Rosetta Code, with one particular example
by ysth (Canon) on Jun 13, 2025 at 16:14 UTC
    Oops, yes, missing g. But did they change the problem? I see "The length of any word shown should have a length > 5."
Re^3: Perl at Rosetta Code, with one particular example
by ikegami (Patriarch) on Jun 13, 2025 at 14:10 UTC

    $h{ $key = tr/e/i/r } is wrong since $_ not set there. Perhaps the = should be a =~?

    (Nevermind)