HELP: how to use an array passed to a function? 
Author Message
 HELP: how to use an array passed to a function?

Quote:

> I would like $gmax to iterate over each value in the array passed in
> as the first argument to this function. The function is called as
> follows:




Try:


Combined wth the function below or look into references ( the best way
to solve this problem ) in the perlref man pages, and also see the FAQ
as to why you will get problems combining scalars and arrays in function
calls.

Quote:

>     my $gmax;
>     print "\$_[0]: ", $_[0], $/;
>     print "\$_[1]: ", $_[1], $/;
>     foreach $gmax ($_[0]) {
>         print "Working with: ", $gmax, $/;
> #       single_line($gmax, $_[1], $_[2]);
>     }
> }

Then change the above to:sub multi_gmax {

  my $gmax;


    print "\nWorking with : $gmax";
  }

Quote:
}

This should get you started I hope.

Simon



Tue, 11 Jan 2000 03:00:00 GMT  
 HELP: how to use an array passed to a function?

I would like $gmax to iterate over each value in the array passed in
as the first argument to this function. The function is called as follows:



    my $gmax;
    print "\$_[0]: ", $_[0], $/;
    print "\$_[1]: ", $_[1], $/;
    foreach $gmax ($_[0]) {
        print "Working with: ", $gmax, $/;
#       single_line($gmax, $_[1], $_[2]);
    }

Quote:
}

--
o============o  Sending unsolicited commercial e-mail (UCE)  to this address
 Legal Notice   is indication of your consent to pay me $120/hour for 1 hour
o============o  minimum for professional proofreading & technical assessment.



Tue, 11 Jan 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. pls help on array list pass to main from a function

2. Passing arrays by reference to C functions and callback functions

3. C function- passing arrays

4. passing two arrays in a function..

5. Passing Associative Arrays to functions

6. Passing an array of function names to a subroutine

7. QUERY: passing array variable by reference to module function

8. Passing Array and/or List to XSUB function

9. : Passing arrays by reference to prototyped functions

10. How to pass associative array in function call

11. array passing to functions

12. Passing and using operators in functions

 

 
Powered by phpBB® Forum Software