Abhishek Dwivedi
TechFreakiez.com
Hi guys
Am kinda new to this section of programming…actually the whole section is new…lol…and this is my first post here, so please pardon any kind of mistake or stupidity…
Perl
This is a bit old language and not used a lot these days but it really helps a lot in the development of security related programs and learning Programming logics and much more...
I’ll keep on updating this post whenever I get time as am just a student of class 11 who is buzzzyyyy in his studies…lol…
Basics :
Perl was developed by Larry Wall in 1987 by fusing Unix Utility with a System Administration Tool that he had developed.
Perl is an interpreted language i.e. its code is run as it is and not compilied like in C++ and other languages.
Before beginning you need to download the Perl Interpreter for windows 32 bit system from here :
*www.activestate.com/
“My First Perl Program”:
In order to write a perl program you do not need any kind of New or Strange Editor…simple editors like notepad will do the work best. (this is the best feature of perl.lol.) Now Open Notepad and type the following :
print ‘This is my first perl program\n’;
Now save this file by the name “Name.pl” (remember to keep the extension as .pl always). Now Open Dos Prompt and type this :
C:\perl>Name.pl (assuming that you save the file in C:\perl\ directory)
When you press Enter,
This is my first perl program
will be printed on the screen….
Now lets analyse this little program…the “PRINT” calls the output function that displays everything from within the quotes on the screen. The “\n” means new line or carriage return. “;” signifies the the statement ends here.
Now lets learn how to use scalars in our program.
Scalars are declared by the $ sign followed by the Variable name which can be anything (without space…you can use‘_’).
Open Notepad and type the following:
$scalarvariable= ‘My First Perl Program\n’;
print “$scalarvariable”;
When you run this program, you will get an output as follows:
My First Perl Program
The 1st line of the program stores the text “My First Perl Program” inside a scalar named scalarvariable and the 2nd line prints the value of scalarvariable on the screen.
Note: Perl performs Variable interpolation within double quotes i.e. it replaces the variable name with the value if the variable.
Lets take one more example:
Open Notepad and type the following:
$scalarvariable= ‘My First Perl Program\n’;
print ‘$scalarvariable’;
The output of this program will be as follows:
$scalarvariable
With the above example example you can easily understand the function of “” and ‘’ in perl.
Interacting with the user is the most important part of the program. In Perl, you can take input from the user using < > operators or the Diamond Operators. This is very similar to the cin function defined in iostream.h of the C++ header file. This operator simply takes the input from the user and waits for the user to press the Enter key and hence it can never be used to halt the screen at any point like the function getch() does…
Open Notepad and type the following:
print ‘Enter your name=’;
$name=<>;
print “\nIs your name $name ?”;
The output of this program will be:
Enter your name= Abhishek
Is your name Abhishek ?
The 1st like prints “Enter your name=” (without quotes) and the 2nd line will ask for the input to store $name. The 3rd line prints “Is your name” value of $name “?”(without quotes) i.e. it will print the value of $name on the screen preceded by “Is your name” (without quotes).
I will be updating this thread daily (frm 4th of nov.) but I would like to know your response on this thread. SO guys please comment…
thanks
Am kinda new to this section of programming…actually the whole section is new…lol…and this is my first post here, so please pardon any kind of mistake or stupidity…
Perl
This is a bit old language and not used a lot these days but it really helps a lot in the development of security related programs and learning Programming logics and much more...
I’ll keep on updating this post whenever I get time as am just a student of class 11 who is buzzzyyyy in his studies…lol…
Basics :
Perl was developed by Larry Wall in 1987 by fusing Unix Utility with a System Administration Tool that he had developed.
Perl is an interpreted language i.e. its code is run as it is and not compilied like in C++ and other languages.
Before beginning you need to download the Perl Interpreter for windows 32 bit system from here :
*www.activestate.com/
“My First Perl Program”:
In order to write a perl program you do not need any kind of New or Strange Editor…simple editors like notepad will do the work best. (this is the best feature of perl.lol.) Now Open Notepad and type the following :
print ‘This is my first perl program\n’;
Now save this file by the name “Name.pl” (remember to keep the extension as .pl always). Now Open Dos Prompt and type this :
C:\perl>Name.pl (assuming that you save the file in C:\perl\ directory)
When you press Enter,
This is my first perl program
will be printed on the screen….
Now lets analyse this little program…the “PRINT” calls the output function that displays everything from within the quotes on the screen. The “\n” means new line or carriage return. “;” signifies the the statement ends here.
Now lets learn how to use scalars in our program.
Scalars are declared by the $ sign followed by the Variable name which can be anything (without space…you can use‘_’).
Open Notepad and type the following:
$scalarvariable= ‘My First Perl Program\n’;
print “$scalarvariable”;
When you run this program, you will get an output as follows:
My First Perl Program
The 1st line of the program stores the text “My First Perl Program” inside a scalar named scalarvariable and the 2nd line prints the value of scalarvariable on the screen.
Note: Perl performs Variable interpolation within double quotes i.e. it replaces the variable name with the value if the variable.
Lets take one more example:
Open Notepad and type the following:
$scalarvariable= ‘My First Perl Program\n’;
print ‘$scalarvariable’;
The output of this program will be as follows:
$scalarvariable
With the above example example you can easily understand the function of “” and ‘’ in perl.
Interacting with the user is the most important part of the program. In Perl, you can take input from the user using < > operators or the Diamond Operators. This is very similar to the cin function defined in iostream.h of the C++ header file. This operator simply takes the input from the user and waits for the user to press the Enter key and hence it can never be used to halt the screen at any point like the function getch() does…
Open Notepad and type the following:
print ‘Enter your name=’;
$name=<>;
print “\nIs your name $name ?”;
The output of this program will be:
Enter your name= Abhishek
Is your name Abhishek ?
The 1st like prints “Enter your name=” (without quotes) and the 2nd line will ask for the input to store $name. The 3rd line prints “Is your name” value of $name “?”(without quotes) i.e. it will print the value of $name on the screen preceded by “Is your name” (without quotes).
I will be updating this thread daily (frm 4th of nov.) but I would like to know your response on this thread. SO guys please comment…
thanks
Last edited: