in reply to <SOLVED>Dereferencing arrays

It's because of the ampersands, see perlsub:
Not only does the & form make the argument list optional, it also disables any prototype checking on arguments you do provide.
$ perl -le 'sub foo(\@) { ref(shift) ? "ref" : "not a ref" }; @arr=(1. +.3); print foo(@arr)' ref $ perl -le 'sub foo(\@) { ref(shift) ? "ref" : "not a ref" }; @arr=(1. +.3); print &foo(@arr)' not a ref

Replies are listed 'Best First'.
Re^2: Dereferencing arrays
by divitto (Novice) on Mar 19, 2014 at 20:37 UTC

    like i said in a previous post (although maybe not fast enough for you to catch it ) i didn't add strict and warnings just for posting. I've adjusted all the flaws everyone has pointed out. I guess i was confused i thought you always had to use the ampersand for method calls. I still get the same string as an array reference error. can somebody please point me in the right direction on that now? EDIT: didnt see the code example, working on it :)

      I understand that the working code changed the merge method to take references but i don't understand why. could you explain that to me? Sorry for the trouble everyone perl's grammer and syntax is confusing for a newbie to it like myself.