in reply to splitting a number into several numbers
But what do you want to do in the general case? Always end up with three numbers? Always get a list of 2 digit numbers?my ($var1, $var2, $var3) = (12, 34, 45);
In the former case, I'd use substr:
In the latter case, a regex will do:my $str = 123445; my $l = int (length ($str) / 3); my $var1 = substr $str, 0, $l; my $var2 = substr $str, $l, $l; my $var3 = substr $str, 2 * $l;
Next time, be more precise in what you want. And having a working example helps too (123345 isn't "12" . "34" . "45").my @vars = $str =~ /..?/g;
Abigail
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: splitting
by kidd (Curate) on Jul 05, 2002 at 13:18 UTC |