![]() |
|
Perl Monk, Perl Meditation | |
PerlMonks |
Re: Splitting every 3 digits?by sifukurt (Hermit) |
on Oct 01, 2001 at 17:21 UTC ( #115854=note: print w/replies, xml ) | Need Help?? |
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:
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
In Section
Seekers of Perl Wisdom
|
|