Section 64. A tramp shall be punished by imprisonment in the house of correction for not more than thirty days; and if he enters a dwelling house or other building without the consent of the owner or occupant thereof, or wilfully or maliciously injures or threatens to injure any person therein, or threatens to do any injury to any person, or to the property of another, or is found carrying a firearm or other dangerous weapon, he shall be punished by imprisonment in the house of correction for not less than one nor more than two and one half years, but notwithstanding the foregoing a tramp found carrying a firearm or other dangerous weapon in violation of section ten of chapter two hundred and sixty-nine may be prosecuted and punished thereunder.