in reply to Passing three arrays to a subroutine

Your prototype is definitely wrong, because any unescaped @ in a prototype eats up all of the remaining arguments. With that said, don't use prototypes; they don't do what you expect them to do, especially here.

We can't debug the rest of the problem because we don't see the rest of the program.

Replies are listed 'Best First'.
Re^2: Passing three arrays to a subroutine
by jaichaud (Initiate) on Nov 09, 2010 at 17:11 UTC
    I am sending three arrays like this:
    @my_arx=(1.0,2.0) @my_ary=(3.0,4.0,5.0) @my_arz=(10.0,20.0,30.0,40.0,50.0,60.0) # z = f(x,y)
    So in my subroutine I don't want to change the array values, but I need to use them in some calculations. The arrays passed to the subroutine are chosen based on some conditions. The calculations work in the subroutine - it is just getting the array values to it. I initially put the arrays in the subroutine until I realized that there would be four different sets of arrays to possibly come into play.
      Thanks for the quick responses. I found the problem - I entered @$my_ref_x in one place and $my_x_ref in the subroutine.

      Sometimes it's hard to see the trees through the forest.

      Thanks again.

        One university computer lab used to have a teddy bear on a table next to the consultant's office. Before you could ask for help, you had to explain your problem to the teddy bear.

        It works without a consulting office, even without a university. Just explain your problem in detail to the teddy bear, or hat, or whatever you have around, and eventually, you'll say something like, "I don't understand why it stops working when i divide by zero."

        If a brief discussion with a shoe doesn't help, write a really, really, detailed message to perlmonks. Don't just cut-and-paste code, but discuss what it should do and what it actually does. If you don't figure out the problem along the way, you can actually submit it for outside assistance.

        As Occam said: Entia non sunt multiplicanda praeter necessitatem.