You are not close at all to producing acronym like: LF,XML,HTML,XHTML. Your code produces:
"L F" "LF" "L.F" "L. F" "HTML" "XML" "X.H.T.M.L" "X. H. T. M. L" "X H T M L"
What do you think this should say? Your code does not produce acronyms.

"An acronym is an initial abbreviation that can be pronounced as a word, such as NASA or WASP. This term is also used to refer to a series of initials pronounced individually, such as FBI or TGIF, but the technical term is initialism."

Update: Perhaps consider this:

#!/usr/bin/perl use strict; use warnings; $|=1; while (my $line = <DATA>) { next if $line =~ /^\s*$/; #skip blank lines $line =~ s/\s*$//; #delete line endings print "INPUT LINE: \'$line\'\n"; $line =~ s/\s+|\,|\.//g; #remove spaces, commas, periods my @acron = $line =~ m/([A-Z]{2,})/g; #get sequence of 2 or #more uppercase chars print "Acronym $_\n" for @acron; } =Prints INPUT LINE: 'L F and LF and L.F. and L. F. and not L, F.' Acronym LF Acronym LF Acronym LF Acronym LF Acronym LF INPUT LINE: 'some HTML some XML.' Acronym HTML Acronym XML INPUT LINE: 'or X.H.T.M.L. or X. H. T. M. L. or even X H T M L' Acronym XHTML Acronym XHTML Acronym XHTML INPUT LINE: 'but not U and I,' INPUT LINE: 'or You and I.' INPUT LINE: '...' =cut __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. ...
Update: Oh, I guess you don't want 'L,' to count...in that case don't delete the comma *see above*

LF, HTML, XML, XHTML are acronyms. something like: X. H. T. M. L. is not.


In reply to Re: Regular expression for finding acronyms by Marshall
in thread Regular expression for finding acronyms by mldvx4

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.