in reply to Re^2: string manipulation
in thread string manipulation
Fair enough. :) I'll see your improvement and raise you this:
use strict; use warnings; my @testStrings = qw{ abc.1.0.1.0 bnnn.1.0.1.1 this.that.1.0.12.0 dots.a.plenty.here.1.0.2.1 }; foreach my $testString ( @testStrings ) { my @parts = split m{\.}, (scalar reverse $testString), 5; my $rest = scalar reverse $parts[4]; my $digits = join q{.}, map{ scalar reverse $_ } reverse @parts[0..3]; print qq{$rest -- $digits\n}; }
If the digits could also be > 10, yours will reverse them (like the this.that in this example is 12, yours would print 21).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: string manipulation
by johngg (Canon) on Jan 13, 2009 at 10:37 UTC |