in reply to Re: string manipulation
in thread string manipulation
... never going to have periods in them it's trivial.
Even if they do it's not too difficult if you split the reversed string with a limit.
use strict; use warnings; my @testStrings = qw{ abc.1.0.1.0 bnnn.1.0.1.1 this.that.1.0.2.0 dots.a.plenty.here.1.0.2.1 }; foreach my $testString ( @testStrings ) { my( $rest, $digits ) = map { scalar reverse( $_->[ 4 ] ), join q{.}, reverse @$_[ 0 .. 3 ] } map { [ split m{\.}, $_, 5 ] } scalar reverse $testString; print qq{$rest -- $digits\n}; }
The output.
abc -- 1.0.1.0 bnnn -- 1.0.1.1 this.that -- 1.0.2.0 dots.a.plenty.here -- 1.0.2.1
I hope this is of interest.
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: string manipulation
by meraxes (Friar) on Jan 12, 2009 at 23:44 UTC | |
by johngg (Canon) on Jan 13, 2009 at 10:37 UTC |