Perl clips - what variable holds selection
- The Help item on using Perl says: (this is for context, pls scroll
to see my question)
"The easiest way to use Perl or Gawk is to store each script in
its own Clip. Then, create an executable Clip with the command to
launch the interpreter that corresponds to the script language you
have written. For example, if you have stored a Perl script for
reversing the order of characters in a Clip labeled "Reverse", all
you need is the following instruction to apply it to the text in
the active document:
If text was selected in the document, then the script will only be
applied to the selection. If no text was selected, then the script
is applied to the whole document (with outline-type documents,
only the current topic is used). The output from the Perl script
then replaces the text to which it was applied."
1. Through what variable is Perl referring to the selected text or
whole document? One of Perl's special variables? WHich? Or is the
text gotten from standard input? Or can I mix languages here and
use a Clip variable in a Perl script?
2. Now if the selection contains just one line (or less), does
Perl treat it as a string?
3. If the selection (or whole document) contains many lines, is it
treated as an array of strings or one big string by Perl?
Been there, done that, anyone?