Re: How can I take subarray without second array (drop other elements)?

2005-04-08 Thread John Doe
Am Donnerstag, 7. April 2005 16.33 schrieb Vladimir D Belousov: John Doe wrote: Am Donnerstag, 7. April 2005 14.54 schrieb Vladimir D Belousov: [...] I do this: $#array = $N+100; print_array($array[$N]); this should be print $array-[$N] I see, but $array here is undefined. It

How can I take subarray without second array (drop other elements)?

2005-04-07 Thread Vladimir D Belousov
Hallo, all! I have a function which prints array: sub print_array { my $array_ref = shift; for(@$array_ref){ print $_\n; } } And I have a big array, for example named @array. I want to print @array elements from N to N+100 using this function, but don't want to use second array (they are

Re: How can I take subarray without second array (drop other elements)?

2005-04-07 Thread Peter Rabbitson
don't want to use second array (they are can be very big). After print I don't need @array anymore. Erm... if you really don't need the array anymore, why don't you just deflate it by splicing on itself? @array = splice (@array, N, 100); Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED]

Re: How can I take subarray without second array (drop other elements)?

2005-04-07 Thread Peter Rabbitson
But this operation means copying an array? Even at return the result from function. And if the array and/or length are very big, it will take a long time and CPU usage. Or I am wrong? The gurus will correct me, but as far as I understand we do a splice on the initial array, take 100

Re: How can I take subarray without second array (drop other elements)?

2005-04-07 Thread John Doe
Am Donnerstag, 7. April 2005 14.54 schrieb Vladimir D Belousov: Hallo, all! Hi Wim has already presented the solution for your problem; [...] I do this: $#array = $N+100; print_array($array[$N]); this should be print $array-[$N] because you have to dereference the arrayref first to

Re: How can I take subarray without second array (drop other elements)?

2005-04-07 Thread Jay Savage
On Apr 7, 2005 8:54 AM, Vladimir D Belousov [EMAIL PROTECTED] wrote: Hallo, all! I have a function which prints array: sub print_array { my $array_ref = shift; for(@$array_ref){ print $_\n; } } And I have a big array, for example named @array. I want to print @array

Re: How can I take subarray without second array (drop other elements)?

2005-04-07 Thread Vladimir D Belousov
John Doe wrote: Am Donnerstag, 7. April 2005 14.54 schrieb Vladimir D Belousov: Hallo, all! Hi Wim has already presented the solution for your problem; [...] I do this: $#array = $N+100; print_array($array[$N]); this should be print $array-[$N] I see, but $array here is

Re: How can I take subarray without second array (drop other elements)?

2005-04-07 Thread Vladimir D Belousov
I'm sorry, as I can see I have explained incorrectly a problem. In main() function I have an array (not the array reference). But function print_array() takes a reference to a part of array. I want to give to print_array() function a reference to a part of array. Array and that part of array may

RE: How can I take subarray without second array (drop other elements)?

2005-04-07 Thread Charles K. Clarkson
Vladimir D Belousov mailto:[EMAIL PROTECTED] wrote: : I want to give to print_array() function a reference to a part of : array. Array and that part of array may be very big and I wish to : avoid excessive copying of data. Therefore I don't want use splice : function. #!/usr/bin/perl use