How to pass an AppleScript variable to Perl script?
The maximum length of a command line is 2**18 bytes:

$ getconf ARG_MAX
262144


So that for example this results in an error:

read "/usr/share/dict/web2" for 270000
do shell script "printf %s " &amp; quoted form of result


If the input is short enough, you can pass it to perl as part of the command line:

read "/usr/share/dict/web2" for 260000
do shell script "printf %s\\\\n " &amp; quoted form of result &amp; "|perl -pe'$_=uc'"


Otherwise you can use a temporary file:

set input to read "/usr/share/dict/web2" for 270000
set f to (system attribute "TMPDIR") &amp; "my.tempfile"
set fd to open for access f with write permission
set eof fd to 0
write input to fd as «class utf8»
close access fd
do shell script "perl -pe'$_=uc' " &amp; f &amp; ";rm " &amp; f


The default text encoding is still an encoding like MacRoman or MacJapanese, so that adding as «class utf8» to the write command preserves non-ASCII characters, even though it is not necessary in the example above.

In your case you could also do something like this:

quoted form of POSIX path of (choose folder)
do shell script "find " &amp; result &amp; " -name \\*.txt|perl -pe'$_=uc'"


quoted form of escapes text for shells, so that it replaces ' with '\'' and surrounds text with single quotes.