This article presents a scheme for a universal device which can be programmed by quantum states to perform optimally a chosen projective measurement, and its implementation in linear optics.