Re: arrays and subroutines

2003-03-17 Thread R. Joseph Newton
David Newman wrote: > Greetings. I have a newbie question about passing arrays into a subroutine > (and getting return values as well). Hi David, I can't help much as far as passing or returning whole arrays, but there is a much better way to access arrays from inside a function. I'll show you

Re: arrays and subroutines

2003-03-16 Thread Victor Tsang
You need to pass the array to the function by reference, here's the fix. &spin([EMAIL PROTECTED]); sub spin { $arr = shift; for (; $count > 0; $count--) { push(@$arr, $start++); } } but if all you want to do is to populate your array with value between 1025 to 1035, here's a clean

arrays and subroutines

2003-03-16 Thread David Newman
Greetings. I have a newbie question about passing arrays into a subroutine (and getting return values as well). My script uses arrays for various values -- one array each for TCP port numbers, UDP port numbers, and the different bytes of IP addresses. Since I have to populate each of these array

Re: Multi-dimensional arrays and subroutines

2002-07-17 Thread Jeff 'japhy' Pinyan
On Jul 17, Ho, Tony said: > $sth->bind_param(1, @$_->[0]); You've already fixed your problem, so that's good, but I would use $sth->bind_param(1, $_->[0]); instead of $sth->bind_param(1, @$_->[0]); Yours works by some bizarre coincidence of Perl's parsing. It should be considere

RE: Multi-dimensional arrays and subroutines - PLEASE IGNORE PREVIOUS EMAIL

2002-07-17 Thread Ho, Tony
gt; Sent: Wednesday, July 17, 2002 11:43 AM > To: '[EMAIL PROTECTED]' > Subject: Multi-dimensional arrays and subroutines > > Hi Guys > I was wondering if you could help me. > > I have a multi-dimensional array and I would like to pass it to a > sub

Multi-dimensional arrays and subroutines

2002-07-17 Thread Ho, Tony
Hi Guys I was wondering if you could help me. I have a multi-dimensional array and I would like to pass it to a subroutine as follows : my @multi_array = ([1,2,3,4], [5,6,7,8]); my @result = process_array(@multi_array); print "The result is : @result\n"; sub process_array { my @array_pro