Perl Program

Domain Hosting image
Web Hosting
Dedicated server
ssl certificate
Web Design image
Email

Our first Perl program will show how to display a line of text on your monitor First, we create a text file to hold the Perl program. Then we run or execute Perl program file. A Perl program consists of an ordinary text file contain series of Perl statements. Statements are written in what looks like an amazon, of C, UNIX shell script, and English. In fact, that's pretty much what it is. Learn, spaces on a line are ignored. We can start a Perl statement anywhere we want the beginning of the line, indented for clarity or even right justified, if we Statements are terminated with a semicolon. Spaces, tabs, and blank outside of strings are irrelevant one space is as good as a hundred. A string basically a series of characters enclosed in quotes. Anything after a hash sign is ignored except in strings.

print(" I am a student of Pentasoft\n ");
Perl should print a newline character after the text, or in other words, go to start of the next line. Printing more text is a matter of either stringing together statements like this, or giving multiple arguments to the print() function:

print(" I am a student of Pentasoft\n ");
print(" I live in Chennai,\n ", " I have come from Bangalore.\n So what does a complete Perl program look like? Here's a small 'example, complete with the invocation line at the top and a few comments: #!/usr/local/bin/perl w

# the above line is used in UNIX platform to indicate the directory in which perl interpreter is located.
print(" I am a student of PentaSoft \n");
print("I live in Chennai,\n", "I have come from Bangalore.\n");
We can create our Perl program by starting any text processor: In UNIX we can use emacs or vi.
In Windows 95/Windows NT we can use notepad or edit.
In OS/2 we can use e or epm.
Create a file called test.pl that contains the preceding three lines. Assuming that Perl is correctly installed and working on our system, the simplest way to run a Perl program is to type the following:
perl [filename].pl
The filename should be replaced by the name of the program that you are trying to run or execute. If you created a "test.pl" file while reading the previous section, you can run it like this: perl test.pl

This example assumes that perl is in the execution path; if not, we will need to supply the full path to perl, too. For example, on UNIX the command might be: /usr/local/bin/perl test.pl

Whereas on Windows NT, you might need to use:
c:\perl5\bin\perl test.pl



Domain Name Search

www.


Copyright (C) 2007. Web Domain design hosting. All rights reserved.