in reply to split, manipulate, join
sub not_so_special { my $s = shift; my @cols = split /;/, $s, -1; my $e; $cols[2] =~ s/=(.+)/'=' . (' ' x length($e = $1))/e; return join ';', @cols, $e }
Update
Or, maybe, more readable and a tiny bit faster:
sub new { my @cols = split /;/, shift, -1; $cols[2] =~ s/=(.+)/=/; $cols[2] .= ' ' x length $1; return join ';', @cols, $1 }
Update 2
This seems even faster (but uglier):
use Syntax::Construct qw{ /r }; sub newer { shift =~ s/^([^;]*;[^;]*;)(.*?=)([^;]*)(;.*)/"$1$2" . (' ' x lengt +h $3) . "$4;$3"/er }
|
|---|