Today I told my friend about my interests in gathering the details…
Lucky the person is ready to share the most possible information with us…
Let me share... the learning's of the day...
PERL VARIABLES:
PERL variables are classified into 3 types. They are as follows...
1. Scalar
2. Array
3. Hash
Scalar Variables:
Scalar Variables are declared using ‘$’. The same variable is capable of handling both strings and numbers values.
For example:
my $sca = 9;
print $sca;
print “\n”;
my $sca = “Scalar Variables”;
print $sca;
The output is:
9
Scalar Variables
Array Variables:
Array variables are declared using ‘@’. We can say list of scalars can be an array variable. Similarly like scalar, array’s also handles both numbers and strings.
For example:
my @arr = (“a”,”b”,”c”);
print 'First value ' . $arr[0];
print 'Second value ' . $arr[2];
The output is:
First Value a
Second Value b
Array variable are classified as variable, its index and value. In the above example ‘arr’ is array, ‘[0]’ is index and ‘a’ is the value.
Indices of an array variable starts with ‘0’ (Zero).
‘$’ can be used as scalar value of an array ‘@’.
To know the number of elements in the array, use '#' before the variable name and it return the index count.
>my @Scal = ("a","b","c","d");
> print "SIZE OF ARRAY $#Scal";
Output:
SIZE OF 3
Hash Variables:
Hash variables are declared using ‘%’. It’s the variant of the array. In array it uses indexing, but hash uses keys for indexing. So hash is classified as key and its value.
For example:
my %has = (‘a’ => ‘1’,’b’ => ‘2’,’c’ =>’3’);
print $has(‘a’);
The output is:
1
These are not arranged in particular order or the way the keys are declared. The values can only be accessed by its key rather than anything else. The values in the Hash variable can be handled by its key; the each key value is again a scalar value.
Hash Variables are shorter than "associative arrays".
Wednesday, February 25, 2009
PERL Docs
You know why I started with PERL...PERL is an intriguing language.
I admire PERL scripting a lot...esteem people who do scripting and who like learning it...
I am not a Hacker...just a learner :)
Giving the PERL Org. URL and installer path won't fulfill my exertion...
In general when we say about some product... people tend to ask...
"Do you have any documents for that...?"
Before you ask me...let me post the links for PERL document reference...
Here it goes...
http://perldoc.perl.org/
Friend of mine installed Strawberry PERL, she was unable to run the scripts... here are the additional things we need to do after installing PERL
Set the 'PATH' environmental variable to the location where you installed Strawberry PERL; say 'C:\Strawberry\bin\'.
Open Edit Plus or Notepad ++ and trying the example mentioned below
This the sample example...
Save the file in certain location, with extension '.pl'.
Open the command prompt, navigate to the location where PERL scripts are saved. Run the following command.
>perl FILENAME.pl
Note: FILENAME.pl is the name of the file you saved earlier.
Have a Happy Start :)
I admire PERL scripting a lot...esteem people who do scripting and who like learning it...
I am not a Hacker...just a learner :)
Giving the PERL Org. URL and installer path won't fulfill my exertion...
In general when we say about some product... people tend to ask...
"Do you have any documents for that...?"
Before you ask me...let me post the links for PERL document reference...
Here it goes...
http://perldoc.perl.org/
Friend of mine installed Strawberry PERL, she was unable to run the scripts... here are the additional things we need to do after installing PERL
Set the 'PATH' environmental variable to the location where you installed Strawberry PERL; say 'C:\Strawberry\bin\'.
Open Edit Plus or Notepad ++ and trying the example mentioned below
This the sample example...
#! /usr/bin/perl
use strict;
use warnings;
my $greeting = "Hello, World!";
print $greeting,"\n"; # Say hello
Save the file in certain location, with extension '.pl'.
Open the command prompt, navigate to the location where PERL scripts are saved. Run the following command.
>perl FILENAME.pl
Note:
Have a Happy Start :)
Give a try to PERL Scripting...
For people who are starting with PERL, the following link helps alot...
http://www.perl.com/pub/a/2008/05/07/beginners-introduction-to-perl-510-part-2.html
Inorder to work on PERL, get the installer from the following location.
http://strawberryperl.com/
Just install PERL and start creating your own PERL files...
Start with print statements... this is the step we initially follows for all programming languages...
http://www.perl.com/pub/a/2008/05/07/beginners-introduction-to-perl-510-part-2.html
Inorder to work on PERL, get the installer from the following location.
http://strawberryperl.com/
Just install PERL and start creating your own PERL files...
Start with print statements... this is the step we initially follows for all programming languages...
Subscribe to:
Posts (Atom)