Hi Everybody, I've tab delimited data as below:
Retid State Rate 25 NJ 7.000 26 NJ 7.000 40 IL 9.750 40 IN 7.000 40 MI 6.000 40 WI 5.500 44 CT 6.000 50 NJ 7.000 87 VA 4.500

I want all unique Retid, comma seperated State & State corresponding to that Retid. Later I would need to add this data into different xml file by comparing Retid (Which is already in other file). I think using hashes would be OK as I don't want to read file everytime (else script will run longer), but not sure how to do this! Could anyone please suggest?

I've tried something like below:
open(IN, $taxFile) || die "$taxFile couldn't be opened $@\n"; while(<IN>) { chomp; @line = split("\t"); $sid = $line[0]; $sidHash{$sid}{state} = $line[1]; $sidHash{$sid}{rate} = $line[2]; }
Output file would be as below, where I'll add these 2 tags i.e. state & rate. Rest tags were read & printed from different file.
<RetId="40"> <name>xyz</name> <url>http://www.xyz.net</url> <type>CPC</type> <logoUrl/> <ntParentAcct>5403020</ntParentAcct> <feedCount>1</feedCount> <feedNumbers>1</feedNumbers> <state>IN, MI, WI</state> <rate>7.000, 6.000, 5.500</rate> </RetId>

In reply to CSV file info into xml tags by CSharma

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.