Perl Syntax


You may notice that Perl looks a bit like a combination of shell scripting and C programming. Like C, Perl requires a semicolon at the end of statements. It uses “\n” to represent a newline. Perl includes some familiar C functions like printf, and as you will see later, for statements in Perl use the C syntax. Like shell scripts, Perl scripts are interpreted rather than compiled. They do not require you to explicitly declare variables, which are global by default. As with shell scripting, Perl makes it easy to integrate UNIX System commands into your script. Comments in Perl scripts start with #, again, just like in the shell.

One thing that’s important to understand about Perl is that the language is very flexible. Many Perl functions allow you to leave out syntax elements that other languages would require-for example, parentheses are often optional, and sometimes you can even leave out the name of a variable. When you read Perl scripts written by other people, you will often see familiar commands being used in new ways. If you’re not sure how something will work, experiment with it.




UNIX. The Complete Reference
UNIX: The Complete Reference, Second Edition (Complete Reference Series)
ISBN: 0072263369
EAN: 2147483647
Year: 2006
Pages: 316

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