Big Chemical Encyclopedia

Chemical substances, components, reactions, process design ...

Articles Figures Tables About

How Scripts Work

A script consists of a series of commands, more formally called statements, that are meaningful to the Perl interpreter. Unless told otherwise, the interpreter starts at the top of the script hie and works its way down to the bottom, executing each statement in turn. [Pg.416]

This script consists of three statements the first one (print I can do math n ) tells the interpreter to print out the indicated text. As we shall discuss in more detail later, the special character sequence n is not interpreted literally but instead prints out as a newline character. The second statement, sum = 3+4, adds the numbers three and four together and stores the result in a variable named sum. The last statement prints the text The sumof3+4is, followed by the contents of the variable sum, followed by a period and a newline. [Pg.416]

The topmost line is also a Perl comment, but on UNIX systems it serves doubleduty as a directive to the UNIX shell to tell it to execute the command /usr/bin/ perl when the script file is executed. On Macintosh and Windows systems, this line is extraneous, but it is better to include it to maintain portability with UNIX machines and as a matter of good form. [Pg.416]

Unless otherwise instructed, the Perl interpreter starts at the first statement and works its way to the last. When this script is run, the following output is produced  [Pg.416]

Notice that the user only sees the output from the two print statements. The statement that performs the addition acts silently, behind the scenes. [Pg.416]


See other pages where How Scripts Work is mentioned: [Pg.416]   


SEARCH



Scripting

© 2024 chempedia.info