http://www.perlmonks.org?node_id=459287


in reply to "Scalar found where operator expected", references

You need a comma between the array and the scalar:

push @weighted, $key;