while () { if (/\w{1,12}\s+(\d{1,5})\s+[a-zA-Z]{4}/sm){ print $1, "\n"; } } __DATA__ BC001593 91 NPSL BC001593 262 NASS BC001593 293 NAST