[Moscow.pm] Как очистить массив
Alexander Onokhov
ccnweb на gmail.com
Чт Май 27 02:20:43 PDT 2010
<code>
ccn на ccn-laptop ~
$ perl -le 'my @a=(1,2,3); while(my $r = shift @a){}; print @a'
ccn на ccn-laptop ~
$ perl -le 'my @a=(0,1,2,3); while(my $r = shift @a){}; print @a'
123
</code>
2010/5/27 Andrew Shitov <andy на shitov.ru>
> Увидел вот такой код внутри класса.
>
> sub clear{
> my $template = shift @args;
> @{$self->{tokens}} = ();
> foreach (map {$_->{name}} @{$template->{si}}){
> while (my $r = shift @{$self->{$_}->{res}}){}
> }
> }
>
>
> Заслуживает внимания способ очистки массива:
>
> while (my $r = shift @a) {}
>
> Клево же :-)
>
> --
> Andrew Shitov
> ______________________________________________________________________
> andy на shitov.ru | http://shitov.ru
> --
> Moscow.pm mailing list
> moscow-pm на pm.org | http://moscow.pm.org
>
--
Alexander
----------- следущая часть -----------
Вложение в формате HTML было извлечено…
URL: <http://mail.pm.org/pipermail/moscow-pm/attachments/20100527/eaa1935d/attachment.html>
Подробная информация о списке рассылки Moscow-pm