Hello MONKS

I am consuming XML service using LWP. And I am parsing XML using XML::Simple. And I have to assign parsed variables to string. When I view variables in browser it shows normal.I am developing KOHA and it uses Template toolkit.

But when I add variables values to database (I am using mysql) it inserted as a HASH. How can I solve this?

My code is
my $rfid= $input->param('rfid'); my $ua = LWP::UserAgent->new; my $response = $ua->get("https:/mywebpage.com/studentservice/s +ervice.asmx/give_to_koha_byStudentCard?cardNR=$rfid"); my $xml=$response->content; # parse my $xs = new XML::Simple(keeproot =>0,searchpath => ".",forcea +rray => 1,); my $ref = $xs->XMLin($xml); my $firstname=${$ref->{firstname}}[0]; my $lastname=${$ref->{lastname}}[0]; my $sisiid=${$ref->{sisiid}}[0]; my $school=${$ref->{school}}[0]; my $program=${$ref->{program}}[0]; my $registerNr=${$ref->{registerNr}}[0]; my $userStatus=${$ref->{userStatus}}[0]; my $usertype=${$ref->{usertype}}[0]; my $photo=${$ref->{photo}}[0]; my $branch=${$ref->{abbrevm}}[0]; my $op= $input->param('op'); # save when op= "save" my %newdata; if($op eq "save"){ %newdata =("cardnumber"=>"$rfid", "surname"=>"$lastname", "firstname"=>"$firstname", "initials"=>"$registerNr", "address"=>"$program", "userid"=>"$sisiid", "categorycode"=>'ST', "branchcode"=>'EZS', "password"=>'aaaaaaa' ); my $borrowernumber=&AddMember(%newdata);
The main problem is assign parsed xml real value to variable.Not a HASH. Thank you.

In reply to {KOHA}Parse XML and assign to variables. by scolife

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.