Hello,

Have a game modding problem and think Perl may be able to solve it. Bash shell scripting failed. No experience with Perl however.

( Yes, this is legal. )

Goal : reorder, in a specific order, in each file alone, the lines of text. And avoid having to hand edit approximately 12,000 ANSI text files.

These ANSI files are in a very loose CSV format. Key pairs / variable = value, for example. Be warned that the "value" is often 'the-rest-of-the-line'.

Started reading 'perldoc intro' ... did not go well.

I have only shell scripting experience and am unable to comprehend/learn high level programming languages ( ASSEMBLY / BASIC = yes, PASCAL / C = no ).

Thank you for your time and consideration.

I have put together the following files. A file name list 'filelist.txt', and a template containing the reordered lines of text ( by first word of the line ) called 'template.txt'.

I can supply an 'unedited' file as well as a 're-ordered' file. The files have an .odf extension but are really renamed ANSI .txt files.

Sample of 'filelist.txt'

bor_adaptorC.odf bor_adaptor_EE_M.odf bor_adaptor_EE.odf bor_adaptor_EO.odf bor_adaptor_OO.odf bor_adaptor_RE.odf bor_adaptor_RO.odf bor_adaptor_TE.odf bor_adaptor_TO.odf bor_adaptor_TR.odf bor_assemblerY.odf bor_assemblerYS.odf bor_assemblerZ.odf bor_assemblerZS.odf bor_assimilator_AAA.odf bor_assimilator_BAA.odf bor_assimilator_BRA.odf bor_assimilator_BTA.odf bor_assimilator_BTR.odf bor_assimilator_BTT.odf

Sample of 'template.txt'

unitname tooltip verbosetooltip race buildtime officercost crewcost dilithiumcost latinumcost metalcost biomattercost maxHealth curHealth healthrate maxshield curShield shieldrate maxSpecialEnergy specialEnergyRate specialenergydisplaymode

In reply to re-ordering lines of text in a file? by moddingforfun

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.