in reply to How to populate a HASH using a FOR loop to a FUNCTION

Your only serious error is that you do not copy the hash into your subroutine when you get the other arguments. Note that you do have to dereference the reference.
my($key); my($val); my(%subHash); $key = shift @_; $val = shift @_; %subHash = %{shift @_};
With this addition, your subroutine will make a copy of the existing hash, add a key/value pair to the copy, and return the copy. Your main program overwrites the old hash with the new one. I believe that this is what you intend.
Bill

Replies are listed 'Best First'.
Re^2: How to populate a HASH using a FOR loop to a FUNCTION
by Gigiux (Initiate) on Dec 27, 2014 at 17:20 UTC
    Dear Bill, thank you your solution works just fine! I am learning Perl 5.8 but since I am doing it on my own I lack most of the best tricks for efficient scripts. My best wishes of happy new year, G
      G, You are doing a good job learning the basic concepts. Your style needs a great deal of improvement. You should find all of the other replies helpful in this respect. Happy new year to you too.
      Bill