perl -le 'print for a .. h' | perl -nle 'if (my $ff = (/d/ .. /h/)) { next unless $ff =~ /(?:^1|E0)$/; print }' d h