my $a = "this"; my $b = "is"; my $c = "a"; my $d = "test"; my $x = "here is the data"; my $e = sprintf("%010d", len($a . $b . $c . $d . $x) + 10); $str = "$a$b$c$d$e$x";