On Thu, 2009-01-29 at 14:39 +0800, itshardtogetone wrote:
> 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 ++;
> }

See `perldoc perldata` and search for /Slices/


-- 
Just my 0.00000002 million dollars worth,
  Shawn

"It would appear that we have reached the limits of what it is
 possible to achieve with computer technology, although one should
 be careful with such statements, as they tend to sound pretty silly
 in 5 years."
   --John von Neumann, circa 1960


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to