try this, @b[0..9] = @a[0..9];
----- 原邮件 ----- 从: itshardtogetone <itshardtoget...@hotmail.com> 日期: 星期四, 一月 29日, 2009 下午2:39 主题: how to copy elements into the next array > Hi, > How do I copy the first 10 elements of @a into @b? > > The method that I use is long :- > my @a = 1..20; > my @b = (); > > my $ctr = 0; > foreach (@a){ > if ($ctr < 10){ > push @b,$_; > } > $ctr ++; > } > > > > > > > Thanks. > > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/