rewrite with perl