Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7168707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:50:01+00:00 2026-05-28T14:50:01+00:00

Example is in PHP but i want to create same associative 2d array in

  • 0

Example is in PHP but i want to create same associative 2d array in perl and how to print that array.
EX in PHP:-

while($row=mysql_fetch_array($rc))
{
    $associative_array[$ClientCode]=array('PartnerCode'=>$row["PartnerCode"],
                                'OldPartnerCode'=>$row["OldPartnerCode"],
                                'ClientCode'=>$ClientCode,
                                'OldClientCode'=> $row["OldClientCode"]);
}

Adding OP’s comment:

If 2d array creation is correct then how to print that array.

$sql_sel="select client_id,partner_id,client_code,partner_code from $tblname"; 
$sth = $dbh->prepare($sql_sel); 
$sth->execute(); 
$nrow=$sth->rows; 
while( ($ccode,$pcode,$old_ccode,$old_pcode) = $sth->fetchrow_array) { 
    $ccode =~ y/A-Z/a-z/; 
    $pcode =~ y/A-Z/a-z/; 
    $old_ccode =~ y/A-Z/a-z/; 
    $old_pcode =~ y/A-Z/a-z/; 
    $client_partner_hash->{$ccode}={
        'newclinetcode'=>$ccode, 
        'newpartnercode'=>$pcode, 
        'oldclinetcode'=>$old_ccode,
        'oldpartnercode'=>$old_pcode
    }; 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:50:03+00:00Added an answer on May 28, 2026 at 2:50 pm

    Here’s a direct translation of the PHP code you posted. It’s not all that different. 🙂

    while (my $row = mysql_fetch_array($rc)) {
        $associative_array->{$ClientCode} = {
            'PartnerCode'    => $row->{'PartnerCode'},
            'OldPartnerCode' => $row->{'OldPartnerCode'},
            'ClientCode'     => $ClientCode,
            'OldClientCode'  => $row->{'OldClientCode'},
        };
    }
    

    Note, of course, that there’s no mysql_fetch_array in Perl. Translate accordingly. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file with .php extention www.example.com/thefile.php?name=123 that I want to direct the
I want PHP to randomly create a multi-dimensional array by picking a vast amount
Since PHP doesn't provide real arrays, I want to create an array class myself.
For example: A.php (the config file): <?php $a = array('name'=>'wine[$index][name]', 'value'=>'wine[$index][value]' ) ?> B.php:
Need your help with my PHP/MYSQL array. I have a php script that selects
I would like to create an array (in php) from sql results like this:
When I create a controller in CodeIgniter, for example login.php. I create a public
I'm using PHP to create some basic HTML. The tags are always the same,
We have a basic service that some people use but most people want their
I want to create folders on the fly, but make it seem like I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.