in reply to Re: Referencing in Function not working correctly.
in thread Referencing in Function not working correctly.

I am using @bonly where function is called from. I need the reference of the array. I didn't want to perl to copy onto another array.
  • Comment on Re^2: Referencing in Function not working correctly.

Replies are listed 'Best First'.
Re^3: Referencing in Function not working correctly.
by jwkrahn (Abbot) on Apr 02, 2010 at 16:00 UTC
    I am using @bonly where function is called from.

    Yes, I can see that.

    I need the reference of the array.

    Yes, that is obvious from the code.

    I didn't want to perl to copy onto another array.

    perl doesn't do any copying.    You however seem to like to copy all your arrays to new arrays.    What is that all about?

    Please explain why you are doing these things.

      "Please explain why you are doing these things."

      I thought it would be safer to copy it in the functions. So, what your saying is if I returned @bonly (as below), perl will not copy it will just give me pointer:
      @bonly = deDuppedArray(\@currentListing, \@previousListing, \@isec_plu +s_bonly );
      My original problem is @bonly changes after the function call and before function ended? Do you know why?
        I thought it would be safer to copy it in the functions.

        Yes it would be safer.

        So, what your saying is if I returned @bonly (as below), perl will not copy it will just give me pointer:
        @bonly = deDuppedArray(\@currentListing, \@previousListing, \@isec_plus_bonly );

        No, the list returned from deDuppedArray() will have to be copied to assign it to the array @bonly.

        My original problem is @bonly changes after the function call and before function ended? Do you know why?

        From the code you posted, there is nothing in the deDuppedArray subroutine that modifies @bonly, directly or indirectly, so no, I don't know why.    What sort of changes are you seeing?