$op = sub { $_[0] eq $_[1] }; if($op->($somvar, "some text")){ #do stuff }