raybies has asked for the wisdom of the Perl Monks concerning the following question:
I've a six character string I'd like to split into three character pairs. I just keep thinking it should be easier to split the string in pairs, than my solution. The closest I can get is this:
$var1 = $1 and $var2 = $2 and $var3 = $3 if /(.{2})(.{2})(.{2})/;
Can anyone think of a more elegant and perly way to do this? Just curious.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: split fixed string into character pairs
by Anonyrnous Monk (Hermit) on Dec 09, 2010 at 15:14 UTC | |
|
Re: split fixed string into character pairs
by JavaFan (Canon) on Dec 09, 2010 at 15:15 UTC | |
|
Re: split fixed string into character pairs
by kennethk (Abbot) on Dec 09, 2010 at 15:11 UTC | |
|
Re: split fixed string into character pairs
by Ratazong (Monsignor) on Dec 09, 2010 at 15:23 UTC | |
|
Re: split fixed string into character pairs
by raybies (Chaplain) on Dec 09, 2010 at 15:46 UTC | |
by Tux (Canon) on Dec 09, 2010 at 15:49 UTC |