added looping solution with perl

recursion was not the most effective solution