QA

 <  Day Day Up  >  

Q&A

Q1:

These things that Perl runs, are they called Perl scripts or Perl programs?

A1:

The name really doesn't matter. Traditionally, programs are compiled into machine code and stored that way, and the machine code can be run many times. On the other hand, scripts are fed to an external program that translates them into actions every time they're run. Larry Wall, creator of Perl, has said that a "script is what you give an actor, a program is what you give an audience." Take that any way you'd like. For the remainder of this book, I'll call them Perl programs, and if you learn well, you can then be known as a Perl programmer .

Q2:

I found my program under Windows using the Explorer and double-clicked on it. A DOS window opened, printed something, and then immediately closed. What's wrong?

A2:

Nothing! The Perl interpreter is associated with the .pl extension as a DOS-mode program. When you clicked on it, a DOS window was opened and the interpreter ran your program and then immediately exited. (It was a short program.) If you actually need to see your Perl program run, open a window and run it manually.

Q3:

In the "Running the Program" section, you hinted at an easier way to run Perl programs under Unix. How?

A3:

First, you must make sure that the #! line of the program is correct, and that the pathname there really points to a perl interpreter; /usr/bin/perl is the usual place for it, or /usr/local/bin/perl on some machines. Next, you must make the program executable by using the chmod command. For the hello program, the Unix shell command would be chmod 755 hello . After that's done, you can run the Perl program by typing hello or ./hello . Hint: Don't ever name your program "test" under Unix. The Unix shells have a command called test , and you'll be very frustrated when the wrong program runs. See your shell's documentation for other names you should avoid.

 <  Day Day Up  >  


SAMS Teach Yourself Perl in 24 Hours
Sams Teach Yourself Perl in 24 Hours (3rd Edition)
ISBN: 0672327937
EAN: 2147483647
Year: 2005
Pages: 241

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net