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


ru.cgi.perl

 
 - RU.CGI.PERL ------------------------------------------------------------------
 From : Artem Chuprina                       2:5020/371.32  11 Oct 2000  11:13:09
 To : Slava Maslikhov
 Subject : Re: как сбросить текущую метку в хеше, при использовании each
 -------------------------------------------------------------------------------- 
 
 <Slava_Maslikhov@p65.f644.n5020.z2.fidonet.org> wrote:
 
 SM> Подскажите, кто знает, как сбросить текущую метку в хеше, при использовании
 SM> функции each.
 SM> Т.е. начав перебирать данные ($ключ, $значение) = each%хеш и недойдя до
 SM> конца, требуется начать снова.
 
 ==== 8< [!perldoc -tf each] ====
     each HASH
             When called in a list context, returns a 2-element array
             consisting of the key and value for the next element of
             a hash, so that you can iterate over it. When called in
             a scalar context, returns the key for only the next
             element in the hash. (Note: Keys may be "0" or "", which
             are logically false; you may wish to avoid constructs
             like `while ($k = each %foo) {}' for this reason.)
 
             Entries are returned in an apparently random order. When
             the hash is entirely read, a null array is returned in
             list context (which when assigned produces a FALSE (0)
             value), and `undef' is returned in a scalar context. The
             next call to each() after that will start iterating
             again. There is a single iterator for each hash, shared
             by all each(), keys(), and values() function calls in
             the program; it can be reset by reading all the elements
                    ^^^^^^^^^^^^^^^
             from the hash, or by evaluating `keys HASH' or `values
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
             HASH'. If you add or delete elements of a hash while
       ^^^^
             you're iterating over it, you may get entries skipped or
             duplicated, so don't.
 
             The following prints out your environment like the
             printenv(1) program, only in a different order:
 
                 while (($key,$value) = each %ENV) {
                     print "$key=$value\n";
                 }
 
             See also keys() and values().
 
 ==== >8 [!perldoc -tf each] ====
 
 -- 
 Счастливо!
   Ран.
 --- ifmail v.2.14.os-p7-tma3
  * Origin: MemoNet (2:5020/371.32@fidonet)
 
 

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

 Тема:    Автор:    Дата:  
 как сбросить текущую метку в хеше, при использовании each   Slava Maslikhov   28 Sep 2000 18:59:18 
 как сбросить текущую метку в хеше, при использовании each   Maxim Y. Zinyakov   09 Oct 2000 16:32:08 
 Re: как сбросить текущую метку в хеше, при использовании each   Artem Chuprina   11 Oct 2000 11:13:09 
Архивное /ru.cgi.perl/17121307077a2.html, оценка 1 из 5, голосов 10
Яндекс.Метрика
Valid HTML 4.01 Transitional