hi monks, I have data like this in a variable. I used XML::Simple to get this data hash stucture

$var1={ 'studentaddres'=>{ 'address'=>[ { 'name'=>'mikky', 'number'=>'12', 'adress'=>' badvel,kadapa,a.p,india', }, { 'name'=>'vijju', 'number'=>'12', 'adress'=>' raipur,ananthapur,a.p,india +', }, { 'name'=>'shyam', 'number'=>'12', 'adress'=>' raighad,rajsthan,india', }, ], 'Subjects'=>[ { 'subjects'=>'7', 'names'=>'EDC,PDc,OS,CN,ITNM,CDS,ENG +LISH', } { 'subjects'=>'3', 'names'=>'EDC,CDS,ENGLISH', } { 'subjects'=>'2', 'names'=>'EDC,PDc', } { 'subjects'=>'5', 'names'=>'EDC,PDc,OS,CN,ITNM', } ], } 'university'=>{ 'name'=>'svu', 'location'=>'ravru', 'branch'=>{ 'electronics'=>{ 'student'=>[ { 'name'=>'mikky', 'number'=>'12', 'semester'=>{ 'Number'=>'1', 'subjects'=>'7', 'rank'=>'1' } }, { 'name'=>'vijju', 'number'=>'15', 'semester'=>[ { 'number'=>'1', 'subjects'=>'3', 'rank'=>'10' }, { 'number'=>'1', 'subjects'=>'2', 'rank'=>'1' } ] }, ] } } }; 'name'=>'sku', 'location'=>'ANTP', 'branch'=>{ 'electronics'=>{ 'student'=>[ { 'name'=>'shyam', 'number'=>'12', 'semester'=>{ 'Number'=>'3', 'subjects'=>'5', 'rank'=>'20' } }, ] } } };

In the above code I have three keys one is studentaddress,subjects and universitys. and I have arrays of values in each key. I have common values in each key like name and number in studentaddress is same in student name and number in the university values. by using similar value in the keys I need to add adress value from studentaddress key to the student tag in the university key. same like subjet names form subject key to the semister tag in the university key. I need help in the perl script to perform this operation. I am very new to perl


In reply to how to add values of one key to the other key value in a hash using perl. by veerubiji

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.