Sharan Basappa wrote:

> Hi,
>
> Is there a way I can copy only part of an array into another array.
> For example, I want to copy only first 8 elements of source array
> into destination array.
>
> Regards

I think you might need this technique

 #!/usr/bin/perl -w
  use strict;
  #
  my @arr1 = (10,11,12,13,14,15,16,17,18,19,20);
  my @arr2 = @arr1[0..7];

  foreach my $ele (@arr1) { printf "arr1 : ".$ele."\n";}
  foreach my $ele (@arr2) { printf "arr2 : ".$ele."\n";}

which gives this output
arr1 : 10
arr1 : 11
arr1 : 12
arr1 : 13
arr1 : 14
arr1 : 15
arr1 : 16
arr1 : 17
arr1 : 18
arr1 : 19
arr1 : 20
arr2 : 10
arr2 : 11
arr2 : 12
arr2 : 13
arr2 : 14
arr2 : 15
arr2 : 16
arr2 : 17

BTW I use a Debian system and use perldoc quite a lot.  To check the
syntax for this problem I did
'perldoc perlintro' and then searched for the word array.  The
solution to your problem is there.  Not sure how you get to this sort
of information on a cygwin platform.

Hope it helps anyway

Regards

L.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to