Различия между Perl 5 и Perl 6

Kirrily "Skud" Robert, Mark Stosberg, Moritz Lenz, Trey Harris, “Differences between Perl 5 and Perl 6”, public translation into Russian from English More about this translation.

See also 34 similar translations

Translate into another language.

Participants

perl5doc.ru514 points
dionys431 points
r3code155 points
And others...
Join Translated.by to translate! If you already have a Translated.by account, please sign in.
If you do not want to register an account, you can sign in with OpenID.
Pages: ← previous Ctrl next next untranslated
1 2 3 4 5 6

Differences between Perl 5 and Perl 6

Различия между Perl 5 и Perl 6

History of edits (Latest: dionys 1 year, 8 months ago) §

— Можно сказать «отличия А от Б», но не «отличия между А и Б». dionys

=head1 NAME

=head1 НАЗВАНИЕ

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

Perl6::Perl5::Differences -- Differences between Perl 5 and Perl 6

Perl6::Perl5::Differences — Различия между Perl 5 и Perl 6

History of edits (Latest: dionys 1 year, 8 months ago) §

=head1 DESCRIPTION

=head1 ОПИСАНИЕ

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

This document is intended to be used by Perl 5 programmers who are new to Perl
6 and just want a quick overview of the main differences. More detail on
everything can be found in the language reference, which have been linked to
throughout.

Этот документ предназначен для тех программистов, которые знают Perl 5, но не знают Perl 6, и интересуются их основными отличиями. Подробнее об отличиях рассказывается в справочном пособии Perl 6.

History of edits (Latest: dionys 1 year, 9 months ago) §

This list is currently known to be incomplete.

Список отличий в настоящее время неполон.

History of edits (Latest: dionys 1 year, 9 months ago) §

=cut

=cut

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

# S02

# SO2

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

=head1 Bits and Pieces

Всякая всячина

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

=head2 Sigils

=head2 Сигилы

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

Where you used to say:

Там, где раньше говорили:

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

my @fruits = ("apple", "pear", "banana");
print $fruit[0], "\n";

my @fruits = ("apple", "pear", "banana");
print $fruit[0], "\n";

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

You would now say:

Теперь бы сказали:

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

my @fruits = "apple", "pear", "banana";
say @fruit[0];

my @fruits = "apple", "pear", "banana";
say @fruit[0];

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

Or even use the C<< <> >> operator, which replaces C<qw()>:

Или даже, используя оператор C<< <> >>, который заменяет C<qw()>:

History of edits (Latest: dionys 1 year, 6 months ago) §

my @fruits = <apple pear banana>;

my @fruits = <apple pear banana>;

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

Note that the sigil for fetching a single element has changed from C<$>
to C<@>; perhaps a better way to think of it is that the sigil of a
variable is now a part of its name, so it never changes in subscripting.

Обратите внимание, что теперь вместо "$" указывается сигил "@".
Может быть лучше думать, что сигил переменной теперь часть его имени, поэтому он никогда не изменяется.

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

The same applies to hashes:

То же самое относится и к хэшам:

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

say "There are %days{'February'} days in February";

say "There are %days{'February'} days in February";

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

Again, there is a shorter form:

Опять же, в сокращенной форме:

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

say "There are %days<February> days in February";

say "There are %days<February> days in February";

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

For details, see L<S02/"Names and Variables">.

За подробностями обращайтесь к разделу L<SO2/"Names and Variables">.

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

=head2 Global variables have a twigil

=head2 Имена глобальных переменных предваряются твигилом

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

Yes, a twigil. It's the second character in the variable name. For globals,
it's a C<*>

Да, твигил. Это второй символ в имени переменной. В глобальных переменных это символ C<*>.

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

Was: $ENV{FOO}
Now: %*ENV<FOO>

Was: $ENV{FOO}
Now: %*ENV<FOO>

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

For details, see L<S02/"Names and Variables">.

Детальнее см. L<SO2/"Names and Variables">.

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

=head2 New ways of referring to array and hash elements

=head2 Новые способы ссылаться на элементы массивов и хэшей

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

Number of elements in an array:

Количество элементов в массиве

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

Was: $#array+1 or scalar(@array)
Now: @array.elems

Было: $#array+1 or scalar(@array)
Стало: @array.elems

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

Index of last element in an array:

Индекс последнего элемента в массиве:

History of edits (Latest: Foxcool 1 year, 10 months ago) §

Was: $#array
Now: @array.end

Было: $#array
Стало: @array.end

History of edits (Latest: Foxcool 1 year, 10 months ago) §

Therefore, last element in an array:

Поэтому, последний элемент массива:

History of edits (Latest: Foxcool 1 year, 10 months ago) §

Was: $array[$#array]
Now: @array[@array.end]
@array[*-1] # beware of the "whatever"-star

Было: $array[$#array]
Стало: @array[@array.end]
@array[*-1] # beware of the "whatever"-star

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

For details, see L<S02/"Built-In Data Types">

Подробнее об этом см. L<S02/"Встроенные типы данных">.

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

=head2 The double-underscore keywords are gone

=head2 Удалены удвоенные символы подчеркивания ключевых слов

History of edits (Latest: perl5doc.ru 1 year, 10 months ago) §

Old New
--- ---
__LINE__ $?LINE
__FILE__ $?FILE
__PACKAGE__ $?PACKAGE
__END__ =begin END
__DATA__ =begin DATA

Старое Новое
--- ---
__LINE__ $?LINE
__FILE__ $?FILE
__PACKAGE__ $?PACKAGE
__END__ =begin END
__DATA__ =begin DATA

History of edits (Latest: Foxcool 1 year, 10 months ago) §
Pages: ← previous Ctrl next next untranslated
1 2 3 4 5 6