add perl version factory-method pattern