- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
use strict;
use warnings;
my $expr = $ARGV[0] || die();
my $n = $ARGV[1] || die();
die if ($n < 1) || ($n > length($expr));
$expr =~ tr/[\xc0-\xdf]\xa8/[\xe0-\xff]\xb8/; # lc
($expr =~ m/^[\xe0-\xff\xb8\-]+$/s) || die();
open(F, 'index') || die("failed to open 'index': $!");
while (<F>)
{
chomp();
print "$_\n" if (match($_, $expr, $n));
}
close(F);
sub match
{
my ($str, $expr, $n) = @_;
return if length($str) != $n;
foreach my $letter (split(//, $str))
{
my $pos = index($expr, $letter);
return if ($pos < 0);
substr($expr, $pos, 1, '');
}
return 1;
}
Комментарии (0) RSS
Добавить комментарий