A scalar variable is a variable in Perl in which we can store exactly one item- a line of input,a piece of text,a number etc.
The name of a scalar variable starts with a dollar ($) sign followed by at least one letter which is followed by any number of digits or letters or underscore (_) sign.
For ex
$x $var $var1 $v_1_3_w
all are valid examples of scalar variables.
For ex
var 12 $12 $_
are not valid examples of scalar variables.
We can assign values to these variables by using assignment operator (=).
As $var=10;
here value 10 is assigned to variable $var.
These variables can be of any length. $this_is_really_a_very_very_very_long_variable
is a valid variable.
The variables are case sensitive in Perl
means $var and $Var are different scalar variables.
Here is a simple program
#!/perl64/bin/perl $scalar_variable=10; print("The value of scalar variable is ", $scalar_variable);
Perl is an interpreted high-level programming language developed by Larry Wall.
Perl stands for practical extraction ans reporting language.It is basically a scripting language, which is compiled each time before running. It is a powerful and famous scripting language now a days.
For writing programs in Perl you just need a text editor in which you can write the program and then save it with .pl extension and you need a Perl interpreter.
So now here is the first program which is hello world in Perl
Program:
#!/perl64/bin/perl print ("Hello, world!\n"); Output: Hello, world!
So now we have run our first Perl program.Its very simple.We use print function for printing anything as output.
On Windows we can use notepad for writing the programs and command prompt for running perl programs.
For this first we have to tell the system where the Perl interpreter is?For this we just go to the folder where the Perl interpreter is.Normally in windows default location for Perl is in C drive .