Sunday, June 13, 2010
Want to learn about Perl? What is Perl? It is one of the oldest web programming language around. Practically every Linux based server comes with support for it by default. Perl is a server-side, scripting language that can output dynamic web pages or web applications. Perl code, like PHP, is run on the server and then gives HTML back to the web browser.
Learn about Perl's capabilities
Because Perl has been around since 1987, it is available on nearly every platform, Windows or Linux. Perl was originally developed for text manipulation but can now be used for managing email, connecting to other web sites or servers, processing form information, storing information in a database, reading and writing to text files, creating cookies in a web browser, and much more. Perl also support subroutines (blocks of code that can do specific things over and over).
Learn About Perl
Learn about Perl's syntax
Perl borrows a lot of syntax from the C programming language. Syntax is the wording and way that the language has to be used for it to work. Perl is designed to be practical so it can be easy to understand but it can also be complex so a higher-level language such as PHP would be a better choice for you if you are a beginning programmer. Perl uses typed variables that store a particular type of data (text, numbers, arrays, scalar, etc.). Here are some important things to learn about Perl:
* Filename. You can name your Perl files anything you like.
* Variables. Most variables are marked by a leading character which identifies the type of variable:
o $foo # a scalar
o @foo # an array
o %foo # a hash
o FOO # a file handle or constant
o &foo # a subroutine. (The & is optional)
* Comments. You can comment out code using the hash character (#).
You can code Perl in any text editor but it may help to use one that has syntax highlighting or other features. What does Perl code look like? Here is a sample:
$yesterday = parsedate('yesterday');
$printdate = strftime('%a, %b %d', localtime($yesterday));
open (FILE, ">$dir/index.html");
for (@index) {
if (/INSERT HERE/) {
print FILE "$_";
print FILE "$printdate\n";
if (($id % 5) == 0) {print FILE "\n"}
}
else {print FILE "$_"};
} # End for
close FILE;
Source:www.host-shopper.com
0 comments:
Post a Comment