[Moscow.pm] Странности и неожиданности Perl
Alexander Alekseev
alex на alemate.ru
Ср Фев 27 06:29:04 PST 2008
Hello!
On Wed, 27 Feb 2008, Alexander Alekseev wrote:
> Видимо всё дело в 'magical auto-increment algorithm' (perlop):
> ------------------------------
> ..
> The range operator (in list context) makes use of the magical
> auto-increment algorithm if the operands are strings. You can say
>
> @alphabet = ('A' .. 'Z');
>
> to get all normal letters of the English alphabet, or
>
> $hexdigit = (0 .. 9, 'a' .. 'f')[$num & 15];
>
> to get a hexadecimal digit, or
>
> @z2 = ('01' .. '31'); print $z2[$mday];
>
> to get dates with leading zeros. If the final value specified is
> not in the sequence that the magical increment would produce, the
> sequence goes until the next value would be longer than the final value
> specified.
> ------------------------------
> Дальше (видимо) надо смотреть исходники. Он же 'magical' !
Хотя можно предположить, что раз '01' .. '31' работает,
значт он сохраняет длину строки. А английский алфавит 'a' .. 'z'
в него зашит.
Bye. Alex.
Подробная информация о списке рассылки Moscow-pm