kalyanrajsista has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks
I've tried the following code in splitting a string into 4 equal parts separated by a space. I've looking for a good method to refine my code or suggest a good way to do....
use strict; my $tempStr = 'BE65826000483296'; my $tempStr1; while ( $tempStr . length ) { $tempStr1 .= " " . substr( $tempStr, 0, 4 ); $tempStr = substr( $tempStr, 4 ); } $tempStr1 =~ s/^\s//isg; print $tempStr1;
Many Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Split string into equal parts
by BrowserUk (Patriarch) on May 28, 2010 at 16:44 UTC | |
by kalyanrajsista (Scribe) on May 29, 2010 at 13:58 UTC | |
|
Re: Split string into equal parts
by ikegami (Patriarch) on May 28, 2010 at 16:48 UTC | |
by AnomalousMonk (Archbishop) on May 28, 2010 at 19:31 UTC | |
by kalyanrajsista (Scribe) on May 29, 2010 at 13:57 UTC | |
by ikegami (Patriarch) on May 31, 2010 at 03:29 UTC | |
|
Re: Split string into equal parts
by johngg (Canon) on May 28, 2010 at 20:44 UTC | |
|
Re: Split string into equal parts
by proceng (Scribe) on May 28, 2010 at 20:24 UTC |