Hello. I want to create a PERL script to convert something like this into XML, with logical headers.

acc_BM: C:\work\workspace\ACC-8.6.0\TAM\plugins\BswM_TS_TxDxM1I14R0\sr +c\BswM.c, 31: warning: redundant redeclaration of 'Com_MainFunctionRx +' [-Wredundant-decls] (included from C:/work/workspace/ACG-8.6.0/TAM/ +plugins/Com_TS_TxDxM6I3R0/include/Com_Api_Static.h, line 1092) extern FUNC(void, COM_CODE) Com_MainFunctionRx ^~~~~~~~~~~~~~~~~~, TestSequences: SwInt_ +ConTest_TestInt_ATS_MODE_ECUM SwInt_ConTest_TestInt_ATS_MODE_RestartE +CUM acc_BC: C:\work\workspace\ACC-8.6.0\tests\Conformance\IN\SwInt_ConTest +_CS_Rte_SomeIpXf_Com_p0\output\generated\src\Com_Lcfg.c, 40: warning: + redundant redeclaration of 'Com_MainFunctionTx' [-Wredundant-decls] +(included from C:/work/workspace/ACG-8.6.0/TAM/plugins/Com_TS_TxDxM6I +3R0/include/Com_Api_Static.h, line 833) extern FUNC(void, COM_CODE) Com_MainFunctionTx ^~~~~~~~~~~~~~~~~~, TestSequences: SwInt_ +ConTest_CS_Rte_SomeIpXf_Com_p0

So the steps would be:

  1. To read all the .txt file(on all lines) that contains that data
  2. To create a blank abc.xml document
  3. To define the XML schema with tags like Module, Path, Warning, Test Sequence
  4. To populate with data the new created .xml file , so it should look like that:
<Warnings> <Module>acc_BM</Module> <Path>C:\work\workspace\ACC-8.6.0\TAM\plugins\BswM_TS_TxDxM1I14R0 +\src\BswM.c</Path> <warning>redundant redeclaration of 'Com_MainFunctionRx' [-Wredun +dant-decls] (included from C:/work/workspace/ACG- 8.6.0/TAM/plugins/Com_TS_TxDxM6I3R0/include/Com_Api_Static.h, li +ne 1092) extern FUNC(void, COM_CODE) Com_MainFunctionRx</warning> <TestSequence>SwInt_ConTest_TestInt_ATS_MODE_ECUM SwInt_ConTest_T +estInt_ATS_MODE_RestartECUM acc_BC: C:\work\workspace\ACC-8.6.0\tests\Conformance\IN\SwInt_C +onTest_CS_Rte_SomeIpXf_Com_p0\output\generated\src\Com_Lcfg.c</TestSe +quence> </Warnings>

It has to be smart, to be self adjust, because for example on test sequences, the names will vary, but will be like XXX.c


In reply to text on multiple lines to XML using PERL by cciiaandrei

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.