M
Marko
First of all, sorry for bad english.
I have the following problem, that can't just seem to get work...
I have a string of numbers that can be from 4 to 20 numbers long. I need
to print this string grouped by 5 numbers and counted by from last to first.
For example:
String = 462345678474
I need = 46 23456 78474
And second example:
String = 4623456784
I need = 46234 56784
I have done the following code, but i dosn't work if the string modulus
five is zero.
Hope you understand better, when loking code...
my $string = "462345678474";
my @array = ();
foreach my $n (split(//, $viite)) {
unshift @array, $n;
}
my $something;
for (my $i = length($string) - 1, my $m = 1; $i >= 0; $i--, $m++) {
if ($m % 5 == 0) {
$viitenro .= " ";
}
$viitenro .= $array[$i];
}
print $something ."\n";
Thanks for advance,
I have the following problem, that can't just seem to get work...
I have a string of numbers that can be from 4 to 20 numbers long. I need
to print this string grouped by 5 numbers and counted by from last to first.
For example:
String = 462345678474
I need = 46 23456 78474
And second example:
String = 4623456784
I need = 46234 56784
I have done the following code, but i dosn't work if the string modulus
five is zero.
Hope you understand better, when loking code...
my $string = "462345678474";
my @array = ();
foreach my $n (split(//, $viite)) {
unshift @array, $n;
}
my $something;
for (my $i = length($string) - 1, my $m = 1; $i >= 0; $i--, $m++) {
if ($m % 5 == 0) {
$viitenro .= " ";
}
$viitenro .= $array[$i];
}
print $something ."\n";
Thanks for advance,