A middle-aged man caught by police literally holding heroin worth £4,000 during a drugs raid has escaped a trip to jail.