# File: string1.pl # Title: Write a string in groups of n=3. Each group on a different line # Author: Mihaela Malita # Input a string? aaabbbcccdddm # aaa # bbb # ccc # ddd # m # Bye $n = 3; #group of 3 print "Input a string? "; $s = ; chop($s); # delete last char for ($i = 0; $i < length($s) ; $i = $i + $n ) { $g = substr($s,$i,$n); #find Group of $n=3 starting form position $i print $g, "\n"; } print "\Bye"; exit;