$\ = $/; # ORS = IRS = "\n" $, = ":"; # OFS = "," while () { chomp; # removes $/ from $_ my @f = split $,; # splits $_ on occurrences of $, # fool around with @f print MOD @f; }