How to glue perverse sheaves