while(){ print "$_\n" if(/$catnum/ ... /$catnum2/); }