my @varbindhashes = (); ... while ($i < @OIDs) { $varbindhashes[$i]->{'OID'} = $OIDs[$i]; ... }