in reply to how to split the string into two or three numbers based on certain value.
It's not really clear what you want if you run out of digits and the last number is less than 32. Maybe something like this will work?
use warnings; use strict; my $string = '79899920179'; my @nums; while (length $string){ no warnings qw/uninitialized/; my $num; $num .= substr($string, 0, 1, '') while (length $string and $num < + 32); push @nums, $num; } print join ', ', @nums;
79, 89, 99, 201, 79
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: how to split the string into two or three numbers based on certain value.
by 7stud (Deacon) on Feb 12, 2013 at 07:08 UTC | |
by choroba (Cardinal) on Feb 12, 2013 at 09:15 UTC | |
by 7stud (Deacon) on Feb 12, 2013 at 18:56 UTC |
In Section
Seekers of Perl Wisdom