Thanks for your interesting help. The more I look at things the more I seem to think that I would like the cleanliness of subroutines. Sad admission, I've been doing most things inside one large "while" loop.

When I used your code I added an open line called "Input" and exchanged my $line = <$fh> with my $line = <Input>. If I didn't do that I got an error:

Name "main::Data" used only once: possible typo at untitled text line +9. readline() on unopened filehandle Data at untitled text line 16.
Ought I have done that?

The output, when I made that change, however looked exactly like the input file. If I gave a sample of the actual text would that help?

&#64257; a bunch of text that isn't important :– dear (13) dear friends (22) love (10) dear friend (10) loved (3) dearly loved (1) friends (1) loved so much (1 [+(xi)1181(-i)]) &#64257; more unimportant text :– competes in the games (1) contend (1) fight (2) fought (1) make every effort (1) strive (1) wrestling (1)

No matter what I tried to mess with I could not get the data to change like you showed in your example.

Thanks for all the help!


In reply to Re^3: Use Perl's Sort to only sort certain lines in a file? by grahambuck
in thread Use Perl's Sort to only sort certain lines in a file? by grahambuck

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.