|
Perl scripts are just ordinary text files. The compilation happens automagically behind the scenes. This is normally considered a good thing because it allows you, the programmer, to focus on things like the newest spy techniques rather than scratching your head at some obscure linking error. With that in mind, however, there is a step required to make it all happen (ironically, called invocation); the computer doesn't know what a Perl program is, but if you tell it where to find the Perl language interpreter, it will happily pass off the task of dealing with the file to it. In Unix, files are identified by special lines that start with #! at the start of the file. This is called the she-bang line and tells your shell what program to use to intrepret the file. For Perl scripts your line should look something like:
#!/usr/local/bin/perl
The location varies according to system, but on all of C&C's UA machines, that's where you find the Perl binaries. If you're totally against thos symbols, or just find it confusing, you can do it all manually by specifying the path to the perl interpreter on the command line and passing the script filename as an argument, like this:
homer01% perl yourscriptname
This could be very useful if you, for instance, wanted to test whether or not a script had syntactic or typographical errors without actually executing (which might be dangerous if you're not sure if it's right, or just time consuming). Perl has a nifty switch that you can use to do just that. If your script has no obvious errors, it works like this:
homer01% perl -c ascript ascript syntax OK
On the other hand, if you made some sort of horrendous mistake, it might look like this:
homer01% perl -c badscript some specific errors ... badscript had compilation errors.
Perl can also be started with the -w flag for additional diagnostic information. Do this.
|