in reply to Reading lines going by 2 characters at a time

You say you "tried the search and replace function" (I can only assume you mean a substitution regex), but don't show your work. It's a whole lot easier for us to help fix your code if you show us your code. Read How (Not) To Ask A Question.

Assuming your input has not been mangled by lack of <code> tags (Markup in the Monastery), you can iterate over the set with a while loop and a regular expression. It might look something like:

#!/usr/bin/perl use strict; use warnings; $_ = '2 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2'; while (/(\d) (\d)/g) { my ($first, $second) = ($1, $2); # insert logic for output }

See Global matching in perlretut.