- Types of PERL variables are :
- Variables do not need to be declared.
- Variable names are case sensitive, so $Date and $date are different variables
- String types in Perl are like those in other programming language. Strings are treated literally when enclosed in quotation marks (either single or double). Escape sequences can be used with Perl strings. These are the most common:
- Some escape sequences for strings have special meaning to Perl:
|\l||change next character to lower case|
|\u||change next character to upper case|
|\||literal single quotation mark|
|\||literal double quotation mark|
|4_348_348||Underscores instead of commas for long numbers|
- Instead of single and double quotes, we can use qq operators. So,
Line1. qq(This is a test)
Line . “This is a test”
#Line 1 & Line 2 has same meaning.
Single and double quotes:
- Double quotation marks allow expansion of variables within them. Single quotes do not.
- For example:
“My name:$name”; is not the same as
- 1st print will fetch the value of $name
- 2nd print will treat $name as a string only;
Variable Declaration :
- Unlike other languages there is no need to declare the variable.
- When the variable is assigned an initial value, Perl can figure out the data type.
Assigning values :
- Variables are assigned values using the equal sign.
$ = This is Sach Kumar ; $d=“Software-developer” ;
- We can assign operation results.