while(){ if($_ =~ C B A R){ do something This bit is not the same for all elements and it is average 100 lines long } if($_ =~ Q U A D){ do something This bit is not the same for all elements and it is average 100 lines long } if($_ =~ C R O D){ do something This bit is not the same for all elements and it is average 100 lines long } if($_ =~ C B E A M){ do something This bit is not the same for all elements and it is average 100 lines long } if($_ =~ C E L A S 1){ do something This bit is not the same for all elements and it is average 100 lines long } ... } #### while(){ if($_ =~ C B A R){ do something This bit is not the same for all elements and it is average 100 lines long } }