http://qs1969.pair.com?node_id=115854


in reply to Splitting every 3 digits?

The only thing you'll have to be wary of with some of the previous examples is if your string, $a, contains a number of digits that isn't evenly divisible by 3, your array won't contain the last 1 or 2 digits. If that is what you want, then you needn't worry about this. If, however, you want the last element in your array to contain the last digits even if the length of your string isn't evenly divisible by 3, you'll want to do something like this:
$a = '12345678901'; while ( $a =~ /(\d{3})/g ) { push ( @nums, $1 ); $last = $'; } if ( length($a) % 3 ) { push ( @nums, $last ); }
In the above example, @nums will contain:
123
456
789
01

There may be a more elegant way of doing this, but it works. Hope this helps.
___________________
Kurt