[Perl] Help with looping through array/hash

Okay I’m really hoping that someone can help me out here. I’m at work and stuck right now because, well let’s just say Perl is not my language. It’s been 10 years since I’ve used it and I can’t remember even some of the basics.

So the company I work for uses Interchange - which in turn is perl based. I dump the contents of my cart and get:

{
  'main' => [ 
     { 
        'mv_ip' => 0,
        'code' => '10111',
        'mv_ib' => 'products',
        'quantity' => '1' 
     }, 
     
     { 
        'mv_ip' => 1,
        'code' => '13112',
        'mv_ib' => 'products',
        'quantity' => '1' 
     }, 
     
     { 
        'mv_ip' => 2, 
        'code' => '81580',
        'quantity' => '1',
        'mv_ib' => 'products' 
     } 
  ] 
}

Now with that I can access a code by doing something like:

$Items->[0]->{'code'};

(Output of above would be 10111)

What I need to do is loop through all of that fun stuff and look for a specific code (let’s say for this example I need to find code 81580). If I find that code I need to get the quantity, remove that whole item with that code. And now add two new products wit the same quantity that I grabed from previously.

This has been killing me all morning and I even hit IRC (no help there). I never considered KirupaForum to be big on Perl, but I thought I’d take a shot.

Sorry 'bout the long post, and thanks in advance to anyone who helps me out.

BTW - What I’m REALLY looking for is a way to loop through that big ugly mess. :wink: