The below code is throwing a syntax error in AppleScript (when using Automator). Any suggestions what may be causing it as the code runs fine when running in Terminal?
on run {input, parameters}
tell application "Terminal"
activate (do script with command "perl -mURI -lne 'print ((URI->new(/([\S]+) \z/msx)->path_segments)[-1])' < testfile.txt > testfile1.txt")
end tell
return input
end run