shoorick: (Default)
[personal profile] shoorick
Продолжаю баловаться двумя языками — перлом и русским:
#!/usr/bin/perl -wl -CS

use strict;
use utf8;

$,=' ';

sub choose_preposition_about_by_next_word {
    return
        /^[аиоуыэ]/i
        ? 'об'
        : 'о';
}

sub choose_preposition_with_by_next_word {
    return
        /^с[^аеёиоуыэюя]/i
        ? 'со'
        : 'с';
}

map {
    print choose_preposition_about_by_next_word, $_;
} qw(
    арбузе баране Елене ёлке игле йоде огне паре ухе юге яблоке
);

map {
    print choose_preposition_with_by_next_word, $_;
} qw(
    огнём садом светом слоном спичками ссылкой
    Стёпой стаканом сухарём сэром топором
);
Наверное, добавлю эти функции в Lingua::RU::Inflect — и можно будет сегодня-завтра выложить версию 0.02.

Date: 2010-02-26 01:43 pm (UTC)
ext_659893: Sapa (Default)
From: [identity profile] sappa.livejournal.com
perldoc perlrun:
            Note: Since perl 5.10.1, if the -C option is used on the #! line,
            it must be specified on the command line as well, since the
            standard streams are already set up at this point in the execution
            of the perl interpreter.  You can also use binmode() to set the
            encoding of an I/O stream.


по моему use encoding является гораздо более читабельным, универсальным и вообще, общепринятым способом назначить кодировки строчный констант в тексте и кодировок для потоков ввода-вывода.

Since

Date: 2010-02-26 05:50 pm (UTC)
From: [identity profile] shoorick.livejournal.com
Ну на рабочей машине у меня, кажется, до сих пор perl 5.8.9 стоит...

Profile

shoorick: (Default)
shoorick

December 2016

S M T W T F S
    1 23
45678910
11121314151617
18 19 2021222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Mar. 21st, 2026 11:53 pm
Powered by Dreamwidth Studios