in reply to Regexp to extract groups of numbers
However, I would prefer to use the substr() function thus:my $pie = 123456789; my @pies = ($pie =~ /(\d{3})/g); print join("\n", @pies);
I choose substr() over unpack() because pack() and unpack() make my brane hurt.$pie = 123456789; my $index = 0; while($index < length($pie)) { print substr($pie, $index, 3)."\n"; $index += 3; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Regexp to extract groups of numbers
by Anonymous Monk on Feb 07, 2005 at 11:21 UTC | |
by demerphq (Chancellor) on Feb 07, 2005 at 11:36 UTC | |
by Anonymous Monk on Feb 07, 2005 at 12:13 UTC | |
by demerphq (Chancellor) on Feb 07, 2005 at 12:31 UTC | |
by halley (Prior) on Feb 07, 2005 at 21:28 UTC |