Главная страница


ru.perl

 
 - RU.PERL ----------------------------------------------------------------------
 From : Dmitry Smolin                        2:5020/949     27 Sep 2002  02:14:16
 To : Sergey V. Leschenko
 Subject : Хеш списков
 -------------------------------------------------------------------------------- 
 
  Once, 26 Sep 2002 16:18, Sergey V. Leschenko wrote to Yuri Mashkovtsev:
 
  >>>  push @{ $nets{$name_comp}}, $n;
  YM>> Здесь lvalue context. Поэтому $nets{$name_comp} автоматически
  YM>> (autovivify) становится ссылкой на анонимный массив.
  SL> а где про это подробней почитать?
 
 perldoc perlreftut:
 
 === Cut ===
 
 There's one fine point I skipped. Suppose the program has just read the
 first line in its input that happens to mention Greece. Control is at
 line 4, "$country" is "'Greece'", and "$city" is "'Athens'". Since this
 is the first city in Greece, "$table{$country}" is undefined---in fact
 there isn't an "'Greece'" key in "%table" at all. What does line 4 do
 here?
 
  4      push @{$table{$country}}, $city;
 
 This is Perl, so it does the exact right thing. It sees that you want to
 push "Athens" onto an array that doesn't exist, so it helpfully makes a
 new, empty, anonymous array for you, installs it in the table, and then
 pushes "Athens" onto it. This is called `autovivification'.
 
 === Cut ===
 
  SL> imho не совсем логичное поведение.
 
 Это как посмотреть. По-моему - в полне в духе perl'а. Читай "логичное".
 
  Take care.
 
 --- skanking to the rhythm of the music by my side
  * Origin: SupportYourLocalSkaBand even though they just may stink (2:5020/949)
 
 

Вернуться к списку тем, сортированных по: возрастание даты  уменьшение даты  тема  автор 

 Тема:    Автор:    Дата:  
 Re: Хеш списков   Sergey V. Leschenko   25 Sep 2002 16:56:29 
 Re: Хеш списков   Yuri Mashkovtsev   25 Sep 2002 23:35:06 
 Re: Хеш списков   Sergey V. Leschenko   26 Sep 2002 16:18:45 
 Хеш списков   Dmitry Smolin   27 Sep 2002 02:14:16 
 Re: Хеш списков   Yuri Mashkovtsev   27 Sep 2002 18:10:31 
Архивное /ru.perl/208523d93884c.html, оценка 2 из 5, голосов 10
Яндекс.Метрика
Valid HTML 4.01 Transitional