Hi I am working with perl catalyst I am new to this. Now I am facing a problem regarding variables. Here I am getting input as hash. Now I need to send this hash variable to another subroutine. Please help me how could I send. I writing the code below how I am using:
if ($csData->{'CUSTOMER_INVOICE_DETAILS'}) { $c->log->debug("API Response:". Dumper $csData->{'CUSTOMER_INVOICE_DET +AILS'}); my $Charges = []; my @customerCharges = $csData->{'CUSTOMER_INVOICE_DETAILS'}; foreach(@customerCharges) { my ($customername,$customeramount) = split /:/; my $charge_hash = ({ customername => $customername, customeramount => $customeramount }); push(@$Charges, $charge_hash); } my @ReturnCharges = $self->API->get_customer_charges($Charges, $Custom +er->customerid, $params->{'invoiceid'});
The other subroutine where this data is receiving is as following:
sub get_customer_charges { my $self = shift; my ($charge, $CustomerId, $INID) = @_; my $http_request = { action => 'GetTariff', customerid => $CustomerId, csid => $INID, }; my $markups = $self->APIRequest($http_request); ##‪#‎Charge‬ Level ID Inserting As 10 my @ChargeLevels; my @BaseLevelID; foreach my $ch (@$charge) { my ($customername,$customeramount) = split(':', $ch->{'customername'}, + $ch->{'customername'}); my $chargelevel = join(':', $ch->{'customername'}, $ch->{'customeramou +nt'}, '10'); push(@BaseLevelID, $chargelevel); } push(@ChargeLevels, @BaseLevelID); return @ChargeLevels; }
Where I am printing server log for CUSTOMER_INVOICE_DETAILS variable I am getting the following values:
API Response:$VAR1 = { 'Product' => '34.04', 'basetax' => '2.38', 'vattax' => '4.36' };
After sending data to second subroutine the data coming in server log for second subroutine variable is as following: Charges in API:$VAR1 = 'HASH(0xb75d6d8)::10'; Can anyone help how could I send the hash data from one subroutine to another? Thanks in advance.

In reply to Convert Hash To Array in Perl Catalyst by jphani225

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.