I am facing some problem while adding values in numeric string:
I have string that looks like 02:03:05:07:04:06
. All the numbers have to be <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).
I the sum>10, then I have add that number to the number in the second last position.
So far, I have
#!/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>=10)
{
I am unable to generate a logic here:(
}
Please help me out of this problem.
After adding the number we have to join the string and print it also :)