in reply to Reading lines going by 2 characters at a time
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.
|
|---|