http://qs321.pair.com?node_id=754555


in reply to multi-line parsing

Another solution, this one without any loops:
use strict; use warnings; my $data; { local $/ = undef; $data = <DATA>; } # my @results = $data =~ m/First Line\nSecond Line\n(\d+)\n/mg; # The m modifier was not really necessary here my @results = $data =~ m/First Line\nSecond Line\n(\d+)\n/g; print join "\n", @results; __DATA__ First Line Second Line 123 First Line Second Line 456 First Line Second Line 789 First Line Second Line 101112 First Line Second Line 131415
Output:
123 456 789 101112 131415

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James