SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Downloaden Sie, um offline zu lesen
42 £ в ойрах
Perl 5.10
появился 17 декабря 2007
Полтора года назад
Кто использует фичи 5.10?
say
given / when
(?<name>.*)
~~
    given($input) {
        when(/$Parser::Money::RatePhrase/)     
                                               
           { }
        when(/$Parser::Money::ConvertPhrase/)  
                                               
           {}

        . . . 

    }
    given($input) {
        when(/$Parser::Money::RatePhrase/)     
                                               
           { }
        when(/$Parser::Money::ConvertPhrase/)  
                                               
           {}

        . . . 

    }
    given($input) {
        when(/$Parser::Money::RatePhrase/)     
                                               
           { }
        when(/$Parser::Money::ConvertPhrase/)  
                                               
           {}

        . . . 

    }
our $ConvertPhrase = qr/
    ^
        ($QuestionWord s)* 
        $CurrencyString 
        (s $ConvertWord)? s
        $CurrencyString
    $
/x;
our $ConvertPhrase = qr/
    ^
        ($QuestionWord s)* 
        $CurrencyString 
        (s $ConvertWord)? s
        $CurrencyString
    $
/x;
my $CurrencyString = qr/
    (?:(?<Value> $Value+) s?)? $CurrencyCode
/x;
my $CurrencyString = qr/
    (?:(?<Value> $Value+) s?)? $CurrencyCode
/x;
my $CurrencyString = qr/
    (?:(?<Value> $Value+) s?)? $CurrencyCode
/x;
our $CurrencyCode = qr/
    b
        (?<code_RUB>
            ru[rb] |
            рубS* |
            рубS* s (россS* | рф) |
            россS* s рубS* |
            рупь |
            деревя[нш]S*
        ) |
        (?<code_EUR>
            euro? |
            € |
            еврS* |
our $CurrencyCode = qr/
    b
        (?<code_RUB>
            ru[rb] |
            рубS* |
            рубS* s (россS* | рф) |
            россS* s рубS* |
            рупь |
            деревя[нш]S*
        ) |
        (?<code_EUR>
            euro? |
            € |
            еврS* |
        (?<code_EUR>
            euro? |
            € |
            еврS* |
            ойрS*
        ) |
        (?<code_USD>
            us[d$] |
            долларов сша |
            (долл?[аео]рS* | 
            баксS* | $) (s (сша | амерS*))? 
            америкS* (s (долларS* | баксS* |
            гринS* |
            баксS*
        (?<code_EUR>
            euro? |
            € |
            еврS* |
            ойрS*
        ) |
        (?<code_USD>
            us[d$] |
            долларов сша |
            (долл?[аео]рS* | 
            баксS* | $) (s (сша | амерS*))? 
            америкS* (s (долларS* | баксS* |
            гринS* |
            баксS*
        (?<code_EUR>
            euro? |
            € |
            еврS* |
            ойрS*
        ) |
        (?<code_USD>
            us[d$] |
            долларов сша |
            (долл?[аео]рS* | 
            баксS* | $) (s (сша | амерS*))? 
            америкS* (s (долларS* | баксS* |
            гринS* |
            баксS*
my @tests = (
    ['курс рубля', 
         {from => 'RUB', value => 0}],
    ['по чем рубль', 
         {from => 'RUB', value => 0}],
    ['рубль',    
         {from => 'RUB', value => 0}],
    ['RUB',  
         {from => 'RUB', value => 0}],
    ['рубль сегодня', 
         {from => 'RUB', value => 0}],
    ['курс RUR', 
         {from => 'RUB', value => 0}],
    ['курс Рубля РФ', 
my @currencyCode = qw(RUR EUR USD JPY CHF GBP UAH 
KZT CAD AUD BYR DKK ISK NOK SEK CNY TRY SGD ILS);

my @currencyNameNominative = ('рубль', 'евро', 
'доллар США', 'японская иена', 'швейцарский франк',
'фунт стерлингов', 'украинская гривна', 
'казахстанский тенге', 'канадский доллар',
'австралийский доллар', 'белорусский рубль', 
'датская крона', 'исландская крона', 'норвежская 
крона', 'шведская крона', 'китайский юань',
'турецкая лира', 'сингапурский доллар', 'шекель');

my @currencyNameGenitive =  ('рубля', 'евро', 
'доллара США', 'японской иены', 'швейцарского 
__END__


Андрей Шитов

http://shitov.ru   |   andy@shitov.ru

Weitere ähnliche Inhalte

Mehr von Andrew Shitov

Creating a compiler in Perl 6
Creating a compiler in Perl 6Creating a compiler in Perl 6
Creating a compiler in Perl 6Andrew Shitov
 
Fun with Raspberry PI (and Perl)
Fun with Raspberry PI (and Perl)Fun with Raspberry PI (and Perl)
Fun with Raspberry PI (and Perl)Andrew Shitov
 
Параллельные вычисления в Perl 6
Параллельные вычисления в Perl 6Параллельные вычисления в Perl 6
Параллельные вычисления в Perl 6Andrew Shitov
 
Perl 6 for Concurrency and Parallel Computing
Perl 6 for Concurrency and Parallel ComputingPerl 6 for Concurrency and Parallel Computing
Perl 6 for Concurrency and Parallel ComputingAndrew Shitov
 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of SmartmatchAndrew Shitov
 
Perl 7, the story of
Perl 7, the story ofPerl 7, the story of
Perl 7, the story ofAndrew Shitov
 
Язык программирования Go для Perl-программистов
Язык программирования Go для Perl-программистовЯзык программирования Go для Perl-программистов
Язык программирования Go для Perl-программистовAndrew Shitov
 
Как очистить массив
Как очистить массивКак очистить массив
Как очистить массивAndrew Shitov
 
What's new in Perl 5.14
What's new in Perl 5.14What's new in Perl 5.14
What's new in Perl 5.14Andrew Shitov
 
Что нового в Perl 5.14
Что нового в Perl 5.14Что нового в Perl 5.14
Что нового в Perl 5.14Andrew Shitov
 
Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6Andrew Shitov
 
There's more than one way to empty it
There's more than one way to empty itThere's more than one way to empty it
There's more than one way to empty itAndrew Shitov
 
How to clean an array
How to clean an arrayHow to clean an array
How to clean an arrayAndrew Shitov
 

Mehr von Andrew Shitov (20)

Perl6 one-liners
Perl6 one-linersPerl6 one-liners
Perl6 one-liners
 
Creating a compiler in Perl 6
Creating a compiler in Perl 6Creating a compiler in Perl 6
Creating a compiler in Perl 6
 
Fun with Raspberry PI (and Perl)
Fun with Raspberry PI (and Perl)Fun with Raspberry PI (and Perl)
Fun with Raspberry PI (and Perl)
 
Perl6 in-production
Perl6 in-productionPerl6 in-production
Perl6 in-production
 
Параллельные вычисления в Perl 6
Параллельные вычисления в Perl 6Параллельные вычисления в Perl 6
Параллельные вычисления в Perl 6
 
AllPerlBooks.com
AllPerlBooks.comAllPerlBooks.com
AllPerlBooks.com
 
Perl 6 for Concurrency and Parallel Computing
Perl 6 for Concurrency and Parallel ComputingPerl 6 for Concurrency and Parallel Computing
Perl 6 for Concurrency and Parallel Computing
 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of Smartmatch
 
YAPC::Europe 2013
YAPC::Europe 2013YAPC::Europe 2013
YAPC::Europe 2013
 
Perl 7, the story of
Perl 7, the story ofPerl 7, the story of
Perl 7, the story of
 
Язык программирования Go для Perl-программистов
Язык программирования Go для Perl-программистовЯзык программирования Go для Perl-программистов
Язык программирования Go для Perl-программистов
 
Как очистить массив
Как очистить массивКак очистить массив
Как очистить массив
 
What's new in Perl 5.14
What's new in Perl 5.14What's new in Perl 5.14
What's new in Perl 5.14
 
Что нового в Perl 5.14
Что нового в Perl 5.14Что нового в Perl 5.14
Что нового в Perl 5.14
 
Perl6 grammars
Perl6 grammarsPerl6 grammars
Perl6 grammars
 
Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6
 
There's more than one way to empty it
There's more than one way to empty itThere's more than one way to empty it
There's more than one way to empty it
 
Perl 6 by example
Perl 6 by examplePerl 6 by example
Perl 6 by example
 
How to clean an array
How to clean an arrayHow to clean an array
How to clean an array
 
Perl 5.10 и 5.12
Perl 5.10 и 5.12Perl 5.10 и 5.12
Perl 5.10 и 5.12
 

‎42 £ в ойрах‎