The key difference between your code and
atcroft's code above is the quotes. With the double quotes in your example, the shell will replace the
$1 before perl gets to see it. Using the single quotes will protect the variable names.
$ echo "19284732 Test message 123456789012345" | perl -pe "s/(\d{8,})/
+scalar localtime $1/e;"
Fri Aug 15 12:52:29 2014 Test message 123456789012345
$ echo "19284732 Test message 123456789012345" | perl -pe 's/(\d{8,})/
+scalar localtime $1/e;'
Tue Aug 11 23:52:12 1970 Test message 123456789012345