Well, a perl program is just a text file containing perl source code. At the top of a perl script is a line like this:
#!/usr/bin/perl
The file must be made executable...
chmod ug+x myscript.pl
...and must be owned by the user or group that wishes to run the script.
chown myname:mygroup myscript.pl
The script can then be invoked from the Terminal like so:
cd /script/folder
./myscript.pl
To run the perl script as an application you can drop the script onto a program called
"DropScript" which converts it into an application. In this case the script should not take any arguments.
Or the script can be invoked from an application built with AppleScript Studio.
Or it can even be invoked by a Widget created for use with
Konfabulator.
In fact, a perl script can be invoked by any program or utility that provides such a facility, including Cocoa applications (which is how DropScript does its magic), the Apple-provided AppleScript Menu, the Script menu of editors like BBEdit, etc. As long as the script is executable and has the correct permissions it's essentially available system-wide.
Cool, huh?
Copy this script into a file, make it executable, and invoke it from the command line. Any text you type will be spoken. Type ctrl-d to exit.
#!/usr/bin/perl -w
# Program: xspeak v1.0 (05 Jan 2002)
# Author: jshaw at sps.lane.edu (http://www.sps.lane.edu/~jshaw)
# Platform: MacOS X 10.1.x
# Synopsis: Simple PERL script that uses Applescript to speak STDIN
# Usage: "foo | xspeak" or "xspeak < filetoread" or just "xspeak" and type some text
$|++; # Flush, just in case
while(<>)
{
$args = "'say \"$_\"'";
system("/usr/bin/osascript -e $args");
}