#! perl -sw use strict; m[> <(.*)>] and print "$1: ", scalar while ; __END__ P:\test>perl 330148.pl < 330148.dat $NAM: (+)-catechin Formula: C15H14O6 MolWeight: 290.26806 ChemBankID: 1254 CompoundName: (+)-catechin Calbiochem Catalog: 219250 MicroSource Catalog: 210205 $NAM: (+)-himbacine Formula: C22H35NO2 MolWeight: 345.51884 ChemBankID: 1861 CompoundName: (+)-himbacine Calbiochem Catalog: 377200 $NAM: (+)-methamphetamine Formula: C10H15N MolWeight: 149.23284 ChemBankID: 1568 CompoundName: (+)-methamphetamine MicroSource Catalog: 1900033