#!/usr/bin/perl -w use strict; while( ) { print if not( /a.*?a/ || /b.*?b/ ); }