It's a Programming Language , written by Larry Wall in late 80's to process mail on Unix systems and since extended by a huge cast of characters.
It's stand for :-
1. Pathologically Eclectic Rubbish Lister
2. Practical Extraction and Report Language
* shall we know properties of the Perl ?
# Interpreted Language
# "Object-Oriented"
# Cross-platform
# Forgiving
# Great for text
# Extensible, rich set of libraries
# Popular for web pages
# Extremely popular for bio-informatics
* How to start the programming in windows :
---------> After completion of the perl installation we need open the cmd , then we need to create one empty directory then we need to write a programm in text editor except ms word then we have to save program name dot pl ( programm.pl) ,
we need go there in cmd I mean where we saved that program then we need to run like this perl program.pl with the Help of cmd .
A simple program in perl :-
open note pad in windows then follow the steps ,
#!usr/bin/perl
# its a simple program which says hello world
# author Siva prasad J
print " Hellow world " ;
and save that program as a program name.pl
then open the cmd and go for that program path and type perl program name.pl
then You may get out put like this Hellow world
The first line
Every perl program starts off with this as its very first line:#!/usr/usr/bin/perlalthough this may vary from system to system. This line tells the machine what to do with the file when it is executed (ie it tells it to run the file through Perl).
Comments and statements
Comments can be inserted into a program with the # symbol, and anything from the # to the end of the line is ignored (with the exception of the first line). The only way to stretch comments over several lines is to use a # on each line. Everything else is a Perl statement which must end with a semicolon, like the last line above.
Simple printing
Theprint function outputs some information. In the above case it prints out the the literal string Hello world. and of course the statement ends with a semicolon. You may find the above program produces an slightly unexpected result. So the next thing to do is to run it.
Let us see a simple program
#!/usr/bin/perl
#This program can Generate an"index.html" file by reading
# other .html files in the current directory.
#
# how can i use this program?
# Unix:
# simple.pl > index.html
# Dos:
# perl simple.pl > index.html
#
#
#
#
# For example, suppose you have a directory with 100
# files, named "1.html" through "100.html". If you want
# to build an index.html page with a bulleted list of all
# files in this directory, just run the program like this:
#
# simple.pl > index.html
#
# Of course, if you're on a DOS/Windows system you'll
# want to run it like this instead:
#
# perl simple.pl > index.html
#
# This program reads the list of HTML files in the current
# directory, and generates a simple, page for you
# automatically.
#
opendir(DIR, ".");
@htmlFiles = grep(/\.html$/,readdir(DIR));
closedir(DIR);
# IT can Prints the HTML index file contents (index.html) to STDOUT.
# This gives you the chance to name the file something else
# when re-directing the output (i.e., "> myfile.html").
print "\n";
print "\n";
print "
- \n";
- $file\n";
}
print "
foreach $file (@htmlFiles) {
print "\t
print "\n";
print "\n";
No comments:
Post a Comment