#!/usr/bin/perl
use 5.016;
use warnings;
use utf8;

open(my $in, '<', \(my $dmy = <<'EOL')) or die;
こういった10行で一組のデータの中に 
--- 
市民の... 

yerles 
warrior 
--- 
というパターンが多くあります。 
マッチ検索したいのは 
--- 
市民の... 

dog 
warrior 
--- 
というパターンです。 
"市民"という文字を見つけたら 
2行下に 
"dog"という文字があるならば 
その、"市民の..."を出力して欲しいです。 
EOL

my @pipe = ('', '', '');
while(<$in>){
	chomp;
	push(@pipe, $_);
	shift(@pipe);

	if (/dog/){
		print $pipe[0], "\n";
	}
}
close($in);
