title: how to add numbers in numeric string in perl
body: <p>I am facing some problem while adding values in numeric string: </p>
  
  <p>I have string that looks like <code>02:03:05:07:04:06</code>. All the numbers have to be &lt;10. Now, I have to take a random number from 1-9  and add that number with last position number of the string (e.g. 3). </p>
  
  <p>I the sum>10, then I have add that number to the number in the second last position. </p>
  
  <p>So far, I have</p>
  
  <pre><code>#!/usr/bin/perl -w
  use strict;
  my $str='02:03:05:07:04:06';
  my @arr=split(/:/,$str);
  my @new_arr=pop(@arr);
  my $rand_val=int(rand(9));
  my $val=$new_arr[0]+$rand_val;
  if($val&gt;=10)
  {
     I am unable to generate a logic here:(
  
  }
  </code></pre>
  
  <p>Please help me out of this problem. </p>
  
  <p>After adding the number we have to join the string and print it also :)</p>