To execute one line of code on a file and print the results to standard output: perl -pe ' your single line of code here ' filename.txt
-e tells perl to execute code between quotes.
-p prints the results to your screen
To execute one line of code on a file, write results to that file and keep a backup copy of the original: perl -p -i~ -e '...your code...' file.txt
The -i tells perl to keep a backup of the original. The ~ is what's appended to the backup file name.