#!/usr/bin/perl use strict; use warnings; my $file = $ARGV[0]; my $check = 0; my @line; while () { @line = split('', $_); $check += 1 if $line[0] eq 'h'; if ($check%2 == 1) { if (($line[0] eq 'j') || ($line[0] eq 'E') || ($line[0] eq 'G')) { print STDOUT "$_"; } } } __DATA__ aaaaa 1 bbbbb 2 hhhhh 3 fffff 4 rrrrr 5 lllll 6 jjjjj 7 HHHHH 8 EEEEE 9 GGGGG 10 hhhhh 11 jjjjj 12 EEEEE 13 GGGGG 14