Match multiline patterns?
#!/usr/local/bin/perl -w use strict; $/ = ""; # Paragraph mode while(<>) { print $1 if /(lines.*\n.*spaces)/s; }