谢谢了!我要做的是,数组中的一个位置之前的全部数据都清出去。我需要对数组中的数据进行判断,就是在push之前还有个if,哈哈!
thanks alot
2009/1/19 Shu Cho <[email protected]>
> 可以这样,
> while ( my $array_elem = shift @array ) {
> push @array_2, $array_elem;
> }
> 很好奇你为什么要这么做。
>
> 另外,在for (@array)里面修改...@array ,就不要去深究为什么了。错误的用法导致奇怪的结果。
>
> 2009/1/19 zhang jy <[email protected]>:
> > hi~
> > 大家好!最近在工作中遇到了一个问题。
> > #!perl -w
> > use strict;
> > my @array=('a','b','c','d','e','f');
> > my @array_2;
> > for(@array)
> > {
> > push @array_2,shift @array;
> > }
> > for(@array)
> > {
> > print $_;
> > }
> >
> > 我希望看到的...@array内被清空,@array_2被填满。可是情况确...@array中存在d,e,f。
> > 请教一下大家,如何才能达到我想要的目的?
> > 还有,为什么存在的是def,而不是b.d.f
> > 谢谢!
> > >
> >
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
您收到此信息是由于您订阅了 Google 论坛“PerlChina 论坛”论坛。
要在此论坛发帖,请发电子邮件到 [email protected]
要退订此论坛,请发邮件至 [email protected]
更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛
-~----------~----~----~----~------~----~------~--~---