basicdez has asked for the wisdom of the Perl Monks concerning the following question:

I am wondering if anyone could help me to understand the art of passing data into a perl script and outputting the data into an XML file.

Please help if you can. I am learning as I go with all of your wonderful knowledge.

peace to all
dez L

"HDR" "from""here""to there" "INI" "123""4444""10.10.10.10" "PER" "A1""14""Fred""Flintstone""03061925""111111111" "PER" "A2""17""Barney""Rubble ""03061927""222222222" "ADR" "A1""111 Rock River Lane""Bedrock""IL""55555" "ADR" "A2""113 Rock River Lane""Bedrock""IL""55555" "EMP" "A1""Rock Foundry""Dinosaur Driver""42000""30""07" "EMP" "A2""Rock Foundry""Clerical Office""41000""25""10" "CBP" "CBI""A1" 0 1 2 05/12/99 07/22/99 "CBP" "CBI""A1" 0 2 3 05/11/65 07/06/71 "CBP" "TRW""A2" 0 1 1 06/05/71 10/24/75 "EOS" "EOS"
So if I take this in, how do I create an XML Tree that looks like the following...

What I really need help with is reading this information into my perl code, not the manipulation of the data.

<?xmlversion = "1.0"?> <APPLICATION> <ACCOUNT> <BEGIN>from</BEGIN> <JOURNEY>here</JOURNEY> <DESTINATION>to there</DETINATION> <COMPANY_CODE>123</COMPANY_CODE> <PORT_ADDRESS>4444</PORT_ADDRESS> <IP_ADDRESS>10.10.10.10</PORT_ADDRESS> </ACCOUNT> <CUSTOMER> <ENTITY_ID>A1</ENTITY_ID> <UNIQUE_ID>14</UNIQUE_ID> <BIRTHDATE>030619</BIRTHDATE> <SSN>111111111</SSN> <NAME> <FIRST_NAME>Fred</FIRST_NAME> <LAST_NAME>Flintstone</LAST_NAME> </NAME> <ADDRESS> <STREET>111 Rock River Lane</STREET> <CITY>Bedrock</CITY> <STATE>IL</STATE> <ZIP>55555</ZIP> </ADDRESS> <EMPLOYMENT> <EMPLOYER>Rock Foundry</EMPLOYER> <OCCUPATION>Dinosaur Driver</OCCUPATION> <SALARY>42000</SALARY> <YEARS_EMPLOYED>30</YEARS_EMPLOYED> <MONTHS_EMPLOYED>7</MONTHS_EMPLOYED> </EMPLOYMENT> </CUSTOMER> <CUSTOMER> <ENTITY_ID>A2</ENTITY_ID> <UNIQUE_ID>17</UNIQUE_ID> <BIRTHDATE>03061927</BIRTHDATE> <SSN>222222222</SSN> <NAME> <FIRST_NAME>Barney</FIRST_NAME> <LAST_NAME>Rubble</LAST_NAME> </NAME> <ADDRESS> <STREET>113 Rock River Lane</STREET> <CITY>Bedrock</CITY> <STATE>IL</STATE> <ZIP>55555</ZIP> </ADDRESS> <EMPLOYMENT> <EMPLOYER>Rock Foundry</EMPLOYER> <OCCUPATION>Clerical Office</OCCUPATION> <SALARY>41000</SALARY> <YEARS_EMPLOYED>25</YEARS_EMPLOYED> <MONTHS_EMPLOYED>10</MONTHS_EMPLOYED> </EMPLOYMENT> </CUSTOMER> <CREDIT_BUREAU> <ENTITY_ID>A1</ENTITY_ID> <UNIQUE_ID>14</UNIQUE_ID> <BUREAU>CBI</BUREAU> <THIRTY_DAYS_LATE>0</THIRTY_DAYS_LATE> <SIXTY_DAYS_LATE>1</SIXTY_DAYS_LATE> <NINETY_DAYS_LATE>2</NINETY_DAYS_LATE> <DATE_BEGAN>05/12/1999</DATE_BEGAN> <DATE_PAID_OFF>07/22/1999</DATE_PAID_OFF> </CREDIT_BUREAU> <CREDIT_BUREAU> <ENTITY_ID>A1</ENTITY_ID> <UNIQUE_ID>14</UNIQUE_ID> <BUREAU>CBI</BUREAU> <THIRTY_DAYS_LATE>0</THIRTY_DAYS_LATE> <SIXTY_DAYS_LATE>2</SIXTY_DAYS_LATE> <NINETY_DAYS_LATE>3</NINETY_DAYS_LATE> <DATE_BEGAN>05/11/1965</DATE_BEGAN> <DATE_PAID_OFF>07/06/1971</DATE_PAID_OFF> </CREDIT_BUREAU> <CREDIT_BUREAU> <ENTITY_ID>A2</ENTITY_ID> <UNIQUE_ID>17</UNIQUE_ID> <BUREAU>TRW</BUREAU> <THIRTY_DAYS_LATE>0</THIRTY_DAYS_LATE> <SIXTY_DAYS_LATE>1</SIXTY_DAYS_LATE> <NINETY_DAYS_LATE>1</NINETY_DAYS_LATE> <DATE_BEGAN>06/05/1971</DATE_BEGAN> <DATE_PAID_OFF>10/24/1975</DATE_PAID_OFF> </CREDIT_BUREAU> </APPLICATION>

Edit: 2001-09-16

Replies are listed 'Best First'.
Re: Developing away here.
by dragonchild (Archbishop) on Sep 14, 2001 at 21:14 UTC
    Well, the way data munging works is you have two (possibly three) steps:
    1. Converting the data from a file to a usable data structure
    2. Maybe you do some comparisons to some other data structure
    3. Output the resultant data structure(s) to another file
    The most important part here is the data structure you use. That will determine how you can think about your data and you can manipulate your data. It looks like you want to use some sort of hash of hashes and foreach over the keys. When you read it in, you're going to populate that hash. When you write it out, you're going to reference that hash.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Re: Developing away here.
by earthboundmisfit (Chaplain) on Sep 14, 2001 at 22:18 UTC