close

My way seems simpler after all. ^^ Though maybe that perl code has more flexibility with all those parameters.