writing in perl, much easier