#!/usr/bin/perl use strict; use warnings; while () { chomp; while( m/([[:upper:]](\.\s|\.|\s|)(?:[[:upper:]](?:\2|$))+)/g ) { my $acronym = $1; print qq("$acronym"\n); } } exit(0); __DATA__ L F and LF and L.F. and L. F. and not L, F. some HTML some XML. or X.H.T.M.L. or X. H. T. M. L. or even X H T M L but not U and I, or You and I. ...