title: Splitting an array to the required format
body: <p>I have an array in Perl like this,</p>
  
  <pre><code>my @a = (
      '12345 abcd efgh ijkl mnop',
      '23456 asdf sdfse ert vsfg',
      '56706 isdua sdf sef mnvsdf',
  )
  </code></pre>
  
  <p>I need to store this in following manner</p>
  
  <ol>
  <li><p>First column alone in a separate variable separated by commas <code>,</code> like this <code>12345,23456,56706</code></p></li>
  <li><p>First two columns separated by colons <code>:</code> which are in turn separated by commas <code>,</code> like this <code>12345:abcd,23456:asdf,56706:isdua</code></p></li>
  </ol>
  
  <p>I was trying the first case but I couldn't find the solution</p>
  
  <pre><code>foreach my $s (@a){
      my @entries = split(/ /, $s); 
      my $_p = $entries[0]; 
      $csv1 = join(',', $_p);
  }
  </code></pre>
  
  <p>I am getting only the last value <code>56706</code></p>
  
  <p>I used <code>$csv2 = $csv2 . "," . $_p;</code> and I got <code>,12345,23456,56706</code></p>
  
  <p>Could someone tell me how to get <code>12345,23456,56706</code> also the second case?</p>