Saturday, September 20, 2008
Perl Vedios
First
Installing the Perl Software Or ClickHere
Or Click Here
How do I get Active Perl Editor
Perl Basics
For to day these are enough we will see latter
Friday, September 19, 2008
Small math ( factorial ) basic program with perl
Hi guys , today we are going to some math programsfor development of our logical ability in that way we need to think of the programming waysSimple Factorial CalculationsThe definition of a factorial: n! = n x (n-1) x (n-2) x ... x 1
|
| |||||||
Basic LoopingLet's learn the white loop today. It looks like this... while (condition) { Examples: are the following True or False? false: 0 | What are conditions? Boolean logic that evaluates to "true" or "false". Numerical: Zero is "false" and non-zero is "true". Comparison operators: ==, !=, <, <=, >, => Text: undefined is "false" and defined is "true". Comparison operators: eq, ne, lt, le, gt, ge Logical grouping Order of operations ** | |||||||
Basic Looping Part 2Now we can write a better factorial program!
Another example, print out your name 100 times
|
Wednesday, September 17, 2008
Perl Basics
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";
Tuesday, September 16, 2008
Perl
Installation guide for windows :-
Windows Prerequisites
• Hardware: 75 MB hard disk space for typical install
• Perl for ISAPI: requires an ISAPI-compatible web server, such as IIS 4.0 or greater, or PWS 4.0 or greater
• PerlScript: requires an ActiveX scripting host such as Internet Explorer 4.0 or greater or Windows Scripting Host
• Perl Environment Variables: if Perl environment variables such as PERLLIB, PERL5LIB or PERL5OPT have been set on your system, you should unset them before installing ActivePerl. Otherwise, these variables may cause incompatible versions of Perl modules to be used during the installation process.
• System Account: (MSI Installer only) Do not launch the installation package from a directory for which the ``System'' account does not have read permission. If you do, the Windows Installer Service will not be able to access the MSI file in order to perform the installation. You may get an error message to this effect, or it may fail mysteriously.
• Administrative Rights: If you are installing Perl on behalf of other users, we recommend running the installer while logged in with an account that has administrative privileges (Windows NT/2000/XP/2003). Running without administrative privileges results in the following limitations:
o The PerlScript feature will be unavailable.
o ActivePerl applications will not write messages to the event log.
o Environment variables are set only for the current user.
o The option to create a file association for Perl files is disabled.
o Registry entries are created under HKEY_CURRENT_USER and not under HKEY_LOCAL_MACHINE.
• Windows XP / Windows 2003 Server: no additional requirements
• Windows 2000
o (MSI Installer only) Microsoft Windows Installer 2.0 or greater, available from: http://downloads.ActiveState.com/contrib/Microsoft/MSI2.0/NT/InstMsiW.exe
• Windows Me
o (MSI Installer only) Microsoft Windows Installer 2.0 or greater, available from: http://downloads.ActiveState.com/contrib/Microsoft/MSI2.0/9x/InstMsiA.exe
• Windows NT
o Service Pack 5 or greater
o (MSI Installer only) Microsoft Windows Installer 2.0 or greater, available from: http://downloads.ActiveState.com/contrib/Microsoft/MSI2.0/NT/InstMsiW.exe
o (for the ActiveX Scripting Engine) Internet Explorer 5 or greater, available from: http://windowsupdate.microsoft.com
• Windows 9x
o (MSI Installer only) Microsoft Windows Installer 2.0 or greater, available from: http://downloads.ActiveState.com/contrib/Microsoft/MSI2.0/9x/InstMsiA.exe
o (for the ActiveX Scripting Engine) Internet Explorer 5 or greater available from: http://windowsupdate.microsoft.com
o (for the ActiveX Scripting Engine) DCOM for Windows 9x, available from: http://www.microsoft.com/com/resources/downloads.asp
o MSVCRT (Windows 95 only), available from: ftp://ftp.microsoft.com/softlib/mslfiles/mxvcrt.exe
Windows Installers
If you are using ActivePerl to serve CGI / ASP scripts using IIS or another Web server, stop the Web server before installing ActivePerl.
MSI Installer Package
To install the MSI package double-click on the MSI file in Windows Explorer.
Do not install over a 500 or 600 series build of ActivePerl. This package must be installed into a separate directory.
MSI Package Installation from the Command Line
You can install ActivePerl from the command line using the 'msiexec' program. For example:
msiexec /i msi_file.msi
The ADDLOCAL command line property is used to specify which features should be installed. (If ADDLOCAL is not specified, all features are installed.) For example:
msiexec /i msi_file.msi ADDLOCAL="PERL_FEATURE,PERLIS"
The following features may be specified with the ADDLOCAL switch:
• PERL_FEATURE (the Perl core)
• PPM (the Programmer's Package Manager)
• PERLIS (the Perl for ISAPI interpreter)
• PERLSE (the Perl ActiveX Scripting Engine)
• EXAMPLES (some simple examples)
• DOCUMENTATION (the ActivePerl documentation)
A set of command-line properties can be used to configure the installation. For example:
msiexec /i msi_file.msi TARGETDIR="c:\perl" PERL_PATH="Yes"
• TARGETDIR: Used to specify the absolute path where ActivePerl will be installed. If not specified, ActivePerl will be installed in a default location on the same drive as the Windows operating system. If this option is used, a value is required.
• PL_IISMAP: If this option is set to 'Yes', the installer will create a global IIS script mapping for '.pl' and Perl. By default, the installation does not create the script mapping.
• PLX_IISMAP: If this option is set to 'Yes', the installer will create a global IIS script mapping for '.plx' and PerlIS. By default, the installation does not create the script mapping.
• PERL_PATH: If this option is set to 'Yes', the Perl/bin directory will be added to the system PATH environment variable. By default, the directory is not added to the path.
The following command-line switches can be used:
Silent Mode
To run in silent mode, specify the '/q' command line option. The installer will run with no UI.
Logging
To log the installation process, specify the '/l' command line option and the name of the log file. For example:
msiexec /i msi_file.msi /l log.txt
To enable verbose logging, use the '*v' modifier with the '/l' command line option. For example:
msiexec /i msi_file.msi /l*v log.txt
AS Installer Package
The AS package is a generic installation package that can be used on systems where the MSI package is not supported. The AS package provides no uninstall functionality. To install using the AS package, double-click the the installer file and follow the prompts.
Windows Configuration
If you run Perl at the command prompt, the script will be executed by the first Perl.exe it encounters in the list of paths in the PATH environment variable. To ensure the script is executed by the Perl interpreter you want it to be executed by, you can specify the complete path to the Perl.exe you want to use. (Typing Perl -v at the command prompt will tell you which version of Perl is currently first in your PATH)
Installing Active Perl will change your Path environment variable and may change registry settings, such as file associations, which may affect your Web server. If you want to use a previously installed copy of Perl, you will need to modify these settings.
Uninstalling Active Perl on Windows
MSI Package
If you installed Active Perl using the MSI installer, uninstall using the Windows Add / Remove Programs applet.
AS Package
If you installed Active Perl using the AS installer, uninstall by deleting the directory in which Active Perl was installed.
Linux Installation guide:
Linux Prerequisites
• Hardware: 75 MB hard disk space for typical install
• Operating System: Red Hat 6.2 or later, Debian 2.2 or later
• Online Help: Web browser
• Perl Environment Variables: if you have set Perl environment variables such as PERLLIB, PERL5LIB or PERL5OPT, you should unset them before installing ActivePerl. Otherwise, these variables may cause incompatible versions of Perl modules to be used during the installation process.
Linux Installers
RPM Package for Red Hat 6.2 or later
The Red Hat compatible package is in RPM format. This should be installed as root, using the following command:
% rpm -i ActivePerl-5.8.4.810-i686-linux.rpm
This will install ActivePerl into /usr/local/ActivePerl-5.8. If you wish to change the default install location, use the --prefix option as follows:
% rpm -i --prefix /opt/ActivePerl-5.8 ActivePerl-5.8.4.810-i686-linux.rpm
To uninstall Activeperl, run:
% rpm -e ActivePerl
The RPM package has only been tested with Red Hat 6.2, but is expected to be compatible with other Red Hat 6.2 compatible installations as well.
DPKG Package for Debian 2.2 or later
The Debian-compatible package is in dpkg format. This should be installed as root, using the following command:
% dpkg -i ActivePerl-5.8.4.810-i686-linux.deb
This will install ActivePerl into /usr/local/ActivePerl-5.8. The dpkg installation package has no mechanism to change the default installation location. Consider installing ActivePerl using the ActivePerl Generic Installer or the RPM package if you need this.
To uninstall ActivePerl, run:
% dpkg -r ActivePerl
The Debian package has only been tested with Debian 2.2, but is expected to be compatible with other Debian 2.2 compatible installations as well.
Generic AS Package for Linux
The generic installer allows installation as an unprivileged user into a user-specified path. GNU tar is required for extracting the files. See ``Known Issues'' in the ActivePerl Release Notes for details.
Download the distribution to a temporary directory, extract the files, chdir to the ActivePerl directory and then run the script ``install.sh''. The installation script will prompt you for the target installation directory.
% tar zxf ActivePerl-5.8.4.810-i686-linux.tar.gz
% cd ActivePerl-5.8.4.810
% ./install.sh
Linux Configuration
The Red Hat and Debian packages are installed into the /usr/local/ActivePerl-5.8 directory. Add the /usr/local/ActivePerl-5.8/bin directory to your PATH environment variable to conveniently access it. For example, in the C shell:
% setenv PATH /usr/local/ActivePerl-5.8/bin:$PATH
The ActivePerl Generic installer allows you to install the package anywhere that the user has write permission. Add the bin directory to your PATH environment variable to conveniently access it. For example, in the C shell (assuming you installed into /home/larry/ActivePerl-5.8):
% setenv PATH /home/larry/ActivePerl-5.8/bin:$PATH
Uninstalling ActivePerl on Linux
Debian Package
If you installed ActivePerl using the DPKG format installer, uninstall as follows:
dpkg -r ActivePerl
RPM Package
If you installed ActivePerl using the RPM format installer, uninstall as follows:
rpm -e ActivePerl
AS Package
If you installed ActivePerl using the AS format installer, remove the directory into which ActivePerl was installed. For example:
/bin/rm -rf /usr/local/ActivePerl-5.8
Installing ActivePerl on Solaris (sparc)
Solaris Prerequisites
• Hardware: 75 MB hard disk space for typical install
• Operating System: Solaris 2.6 or later
• Online Help: Web browser
• Perl Environment Variables: if you have set Perl environment variables such as PERLLIB, PERL5LIB or PERL5OPT, you should unset them before installing ActivePerl. Otherwise, these variables may cause incompatible versions of Perl modules to be used during the installation process.
Solaris Installers
PKGADD Package
The Solaris package is in pkgadd format. This should be installed as root, using the following commands:
% gunzip ActivePerl-5.8.4.810-sun4-solaris.pkg.gz
% pkgadd -d ActivePerl-5.8.4.810-sun4-solaris.pkg
pkgadd will query you for the installation location, which can be changed from the default of /usr/local/ActivePerl-5.8.
To uninstall ActivePerl, run:
% pkgrm ASperl
This package has only been tested with Solaris 2.6, but is expected to be compatible with other Solaris 2.6 compatible installations as well, including Solaris 2.7 and Solaris 2.8.
Generic AS Package for Solaris
The Generic Installer allows installation as an unprivileged user, and into a user-specified path. GNU tar is required for extracting the files. See ``Known Issues'' in the ActivePerl Release Notes for details.
Download the distribution to a temporary directory, extract the files, chdir to the ActivePerl directory and then run the script ``install.sh''. The installation script will prompt you for the target installation directory.
% tar zxf ActivePerl-5.8.4.810-sun4-solaris.tar.gz
% cd ActivePerl-5.8.4.810
% ./install.sh
Solaris Configuration
The Solaris package is installed into the /usr/local/ActivePerl-5.8 directory. Add the /usr/local/ActivePerl-5.8/bin directory to your PATH environment variable to conveniently access it. For example, in the C shell:
% setenv PATH /usr/local/ActivePerl-5.8/bin:$PATH
The ActivePerl Generic installer allows you to install the package anywhere that the user has write permission. Add the bin directory to your PATH environment variable to conveniently access it. For example, in the C shell (assuming you installed into /home/larry/ActivePerl-5.8):
% setenv PATH /home/larry/ActivePerl-5.8/bin:$PATH
Uninstalling ActivePerl on Solaris
PKGADD Package
If you installed ActivePerl using the PKGADD format installer, uninstall as follows:
pkgrm -d ASperl
AS Package
If you installed Active Perl using the AS format installer, remove the directory into which Active Perl was installed. For example:
/bin/rm -rf /usr/local/ActivePerl-5.8