Difference between revisions of "PERL/C2/Variables-in-Perl/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
 
{| border=1
 
{| border=1
! <center>'''Visual Cue'''</center>
+
| '''Time'''
! <center>'''Narration'''</center>
+
| '''Narration'''
  
 
|-
 
|-
| 00.01
+
| 00:01
| Welcome to the spoken tutorial on Variables in '''Perl'''.  
+
| Welcome to the spoken tutorial on '''Variables in Perl'''.  
  
 
|-
 
|-
| 00.07
+
| 00:06
|  In this tutorial, we will learn about Variables in '''Perl'''
+
|  In this tutorial, we will learn about '''variables''' in '''Perl'''.
  
 
|-
 
|-
|  00.12
+
|  00:12
 
|  I am using '''Ubuntu Linux12.04''' operating system and  
 
|  I am using '''Ubuntu Linux12.04''' operating system and  
  
 
|-
 
|-
| 00.18
+
| 00:18
| '''Perl''' '''5.14.2 ''' that is, '''Perl''' revision 5 version 14 and subversion 2
+
| '''Perl''' '''5.14.2 ''' that is: '''Perl''' revision 5, version 14, and subversion 2.
 
+
  
 
|-
 
|-
| 00.26
+
| 00:26
 
| I will also be using the '''gedit Text Editor'''.  
 
| I will also be using the '''gedit Text Editor'''.  
  
 
|-
 
|-
| 00.31
+
| 00:30
 
| You can use any text editor of your choice.
 
| You can use any text editor of your choice.
  
 
|-
 
|-
| 00.35
+
| 00:34
 
|  '''Variables''' in '''Perl''':
 
|  '''Variables''' in '''Perl''':
  
 
|-
 
|-
| 00.37
+
| 00:37
| '''Variables''' are used for storing values, like text strings, numbers or arrays.
+
| '''Variables''' are used for storing values like text strings, numbers or arrays.
  
 
|-
 
|-
| 00.45
+
| 00:44
| Once a '''variable''' is declared, it can be used over and over again in the script.
+
| Once a variable is declared, it can be used over and over again in the script.
  
 
|-
 
|-
|  00.50
+
|  00:50
 
|  '''Scalar''' represents a single value and can store '''scalars''' only.
 
|  '''Scalar''' represents a single value and can store '''scalars''' only.
  
 
|-
 
|-
| 00.56
+
| 00:56
| '''Scalar variables''' are declared using $ ('''dollar''') symbol.
+
| '''Scalar''' variables are declared using $ (dollar) symbol.
  
 
|-
 
|-
|  01.00
+
|  01:00
|  Let us look at '''Variable Declaration''':
+
|  Let us look at '''variable''' declaration.
  
 
|-
 
|-
| 01.03
+
| 01:03
| A '''variable''' can be declared as follows: '''dollar priority semicolon'''
+
| A variable can be declared as follows: '''dollar priority semicolon'''.
 
+
  
 
|-
 
|-
| 01.09
+
| 01:09
| '''Variable''' names in '''Perl''' can have several formats. '''Variables''' must begin with a letter or '''underscore'''  
+
| '''Variable''' names in '''Perl''' can have several formats. Variables must begin with a letter or '''underscore''' (_).
  
 
|-
 
|-
|  01.18
+
|  01:18
|  And may contains letters, digits, '''underscores''' or a combination of above 3.
+
|  And may contain letters, digits, '''underscores''' or a combination of above three.
  
 
|-
 
|-
|  01.24
+
|  01:24
'''Variables''' declared with CAPITAL letters have special meaning in '''Perl.'''  
+
|  Variables declared with CAPITAL letters have special meaning in '''Perl.'''  
  
 
|-
 
|-
| 01.30
+
| 01:30
| So avoid declaring '''variables''' using Capital letters.
+
| So, avoid declaring variables using capital letters.
  
 
|-
 
|-
|  01.34
+
|  01:34
|  Now open the '''Terminal''' and type  '''gedit variables dot pl ampersand '''
+
|  Now open the '''Terminal''' and type: '''gedit variables dot pl ampersand'''(&)
 
+
  
 
|-
 
|-
| 01.44
+
| 01:44
| The '''ampersand''' will unlock the command prompt on the '''terminal'''. Now press '''Enter'''.
+
| The '''ampersand''' will unlock the '''command prompt''' on the '''terminal'''. Now press '''Enter'''.
  
 
|-
 
|-
| 01.50    
+
| 01:50    
|  This will open the '''variables.pl '''file in '''gedit''' text editor.
+
|  This will open the '''variables.pl '''file in '''gedit''' '''text editor'''.
  
 
|-
 
|-
| 01.56
+
| 01:56
| '''dot pl '''is the default extension of a '''Perl''' file.
+
| '''dot pl''' (.pl) is the '''default''' '''extension''' of a '''Perl''' file.
  
 
|-
 
|-
|  02.01
+
|  02:01
|  Type the following in the file; '''dollar priority semicolon''' and press '''Enter'''.
+
|  Type the following in the file: '''dollar priority semicolon''' and press '''Enter'''.
  
 
|-
 
|-
|  02.10
+
|  02:10
 
|  So we have declared the '''variable priority'''.
 
|  So we have declared the '''variable priority'''.
  
 
|-
 
|-
| 02.13
+
| 02:13
| You do not need to declare a '''variable''' before using it;
+
| You do not need to declare a variable before using it;
  
 
|-
 
|-
| 02.18  
+
| 02:18  
 
| you can just use it into your code.  
 
| you can just use it into your code.  
  
 
|-
 
|-
|  02.21  
+
|  02:21  
|  Now let us assign a numerical value to the '''variable priority'''.  
+
|  Now let us assign a numerical value to the variable '''priority'''.  
  
 
|-
 
|-
| 02.26
+
| 02:25
| For this type '''dollar priority space equal to space one semicolon'''
+
| For this, type: '''dollar priority space equal to space one semicolon'''
  
 
|-
 
|-
| 02.33
+
| 02:32
 
| and press '''Enter'''.
 
| and press '''Enter'''.
  
 
|-
 
|-
| 02.34  
+
| 02:34  
|  Next, type
+
|  Next, type:
  
 
|-
 
|-
| 02.36
+
| 02:36
| '''print space double quote Value of variable is: dollar priority slash n double quote complete semicolon''' and press enter
+
| '''print''' space double quote '''Value of variable is:''' dollar '''priority''' backslash '''n''' close double quote semicolon and press '''Enter'''.
  
 
|-
 
|-
| 02.51
+
| 02:50
| '''slash n''' is the new line character.
+
| '''backslash n''' is the "new line" character.
  
 
|-
 
|-
|  02.53
+
|  02:53
|  Now save this file as '''variables.pl''' at any location.
+
|  Now '''save''' this file as '''variables.pl''' at any location.
  
 
|-
 
|-
| 03.02
+
| 03:02
| In my case, it will get saved in '''/home/amol '''directory. Now save this file
+
| In my case, it will get saved in '''home/amol '''directory. Now '''save''' this file.
  
 
|-
 
|-
| 03.11
+
| 03:10
|  Now, let us change the permissions of '''variables.pl''' file, which we just now created.
+
|  Now, let us change the permissions of '''variables.pl''' file which we just now created.
  
 
|-
 
|-
| 03.18
+
| 03:18
 
| To do so, on the '''Terminal''' type, '''chmod 755 variables dot pl'''
 
| To do so, on the '''Terminal''' type, '''chmod 755 variables dot pl'''
  
 
|-
 
|-
| 03.27
+
| 03:27
| This will provide read, write & execute rights to the file.
+
| This will provide "read", "write" & "execute" rights to the file.
  
 
|-
 
|-
|  03.33
+
|  03:32
|  To compile this '''Perl''' script, on the '''Terminal'''
+
|  To compile this '''Perl''' script, on the '''Terminal''',
  
 
|-
 
|-
| 03.36
+
| 03:36
| type ;'''perl hyphen c variables dot pl'''
+
| type: '''perl hyphen c variables dot pl'''
  
 
|-
 
|-
|  03.42
+
|  03:42
 
|  '''Hyphen c '''switch compiles the '''Perl''' script for any compilation/syntax error.
 
|  '''Hyphen c '''switch compiles the '''Perl''' script for any compilation/syntax error.
  
 
|-
 
|-
|  03.49
+
|  03:49
| Now press '''Enter'''
+
| Now press '''Enter'''.
  
 
|-
 
|-
| 03.51
+
| 03:51
 
| This tells us that there is no syntax error in our script.
 
| This tells us that there is no syntax error in our script.
  
 
|-
 
|-
|  03.56
+
|  03:56
|  Now let's execute the '''Perl''' script by typing '''perl variables dot pl''' and press '''Enter'''.
+
|  Now let us execute the '''Perl''' script by typing '''perl variables dot pl''' and press '''Enter'''.
  
 
|-
 
|-
|  04.06
+
|  04:06
 
|  The output displayed is as highlighted.
 
|  The output displayed is as highlighted.
  
 
|-
 
|-
|  04.10
+
|  04:10
 
|  We can also assign a '''string''' value to the '''variable''' we declared.
 
|  We can also assign a '''string''' value to the '''variable''' we declared.
  
 
|-
 
|-
| 04.15
+
| 04:15
 
| Switch back to the Text editor window.
 
| Switch back to the Text editor window.
  
 
|-
 
|-
|  04.18
+
|  04:18
|  Instead of '''dollar priority equal to one;''' type
+
|  Instead of '''dollar priority equal to one;''' type:
  
 
|-
 
|-
| 04.22
+
| 04:22
| '''dollar priority equal to in single quote high '''
+
| '''dollar priority''' equal to in single quotes '''high''';
  
 
|-
 
|-
|  04.28
+
|  04:28
 
|  Please note that  the assignments are evaluated from right to left.
 
|  Please note that  the assignments are evaluated from right to left.
  
 
|-
 
|-
| 04.34
+
| 04:34
| A '''scalar''' can hold data of any type, be it a '''string''', a number  
+
| A '''scalar''' can hold data of any type, be it a '''string''', a number.
  
 
|-
 
|-
|  04.39
+
|  04:38
|  Save this file and compile the script once again by typing
+
'''Save''' this file and compile the script once again by typing:
 
+
  
 
|-
 
|-
| 04.45
+
| 04:45
 
| '''perl hyphen c variables dot pl''' now press '''Enter'''.
 
| '''perl hyphen c variables dot pl''' now press '''Enter'''.
  
 
|-
 
|-
|  04.51  
+
|  04:51  
 
|  This tells us that there is no syntax error.
 
|  This tells us that there is no syntax error.
 
  
 
|-
 
|-
| 04.55
+
| 04:55
| Execute the script by typing '''perl variables dot pl''' and press '''Enter'''.
+
| '''Execute''' the script by typing '''perl variables dot pl''' and press '''Enter'''.
  
 
|-
 
|-
|  05.04
+
|  05:03
|  The output is as shown.
+
|  The '''output''' is as shown.
  
 
|-
 
|-
|  05.07
+
|  05:07
|  Now switch back to the Text Editor window.
+
|  Now switch back to the '''Text Editor''' '''window'''.
 
+
  
 
|-
 
|-
| 05.10
+
| 05:10
| You can also use '''scalars''' within a double-quoted '''strings''' as
+
| You can also use '''scalars''' within a double-quoted '''string''' as
  
 
|-
 
|-
| 05.15
+
| 05:15
| '''dollar priority in double quote String'''
+
| '''dollar priority''' in double quotes '''string''';
 
+
  
 
|-
 
|-
| 05.20
+
| 05:19
| Save this file and close it.
+
| '''Save''' this file and close it.
  
 
|-
 
|-
|  05.22  
+
|  05:22  
let us learn how to declare multiple '''variables'''.
+
Let us learn how to declare multiple variables.
  
 
|-
 
|-
| 05.27  
+
| 05:27  
| To do so open the new file in Text Editor.
+
| To do so, open the new file in Text Editor.
  
 
|-
 
|-
|  05.31
+
|  05:31
on'''Terminal''' type - '''gedit multivar dot pl space ampersand''' and press '''Enter'''.
+
On'''Terminal''', type'''gedit multivar dot pl space ampersand''' and press '''Enter'''.
 
+
  
 
|-
 
|-
| 05.43
+
| 05:42
| This will open '''multivar dot pl''' file in text editor
+
| This will open "multivar dot pl" file in text editor.
  
 
|-
 
|-
|  05.48
+
|  05:48
|  Now type -
+
|  Now, type:
  
 
|-
 
|-
| 05.50
+
| 05:50
 
| '''dollar firstVar comma dollar secondVar semicolon''' and press '''Enter'''.
 
| '''dollar firstVar comma dollar secondVar semicolon''' and press '''Enter'''.
  
 
|-
 
|-
|  06.00
+
|  06:00
|  To copy the value of variable '''dollar firstVar''' to '''dollar secondVar''', type -
+
|  To copy the value of variable '''dollar firstVar''' to '''dollar secondVar''', type:
  
 
|-
 
|-
| 06.08
+
| 06:07
 
| '''dollar firstVar space equal to space dollar secondVar semicolon''' and press '''Enter'''.
 
| '''dollar firstVar space equal to space dollar secondVar semicolon''' and press '''Enter'''.
  
 
|-
 
|-
|  06.19
+
|  06:19
|  All mathematical operations like addition, subtraction, multiplication, division, can be done on these variables  
+
|  All mathematical operations like addition, subtraction, multiplication, division, can be done on these variables.
  
 
|-
 
|-
| 06.30
+
| 06:30
 
| Let us see how we can achieve this using '''Perl'''.
 
| Let us see how we can achieve this using '''Perl'''.
  
 
|-
 
|-
| 06.34  
+
| 06:34  
|  Switch to text editor.
+
|  Switch to '''text editor'''.
  
 
|-
 
|-
| 06.36
+
| 06:36
| And now let us assign the value '''10''' to both these variables by typing,  
+
| And now let us assign the value '''10''' to both of these variables by typing,  
  
 
|-
 
|-
| 06.41
+
| 06:41
| '''dollar firstVar equal to dollar secondVar equal to ten semicolon''' And Press '''Enter'''.
+
| '''dollar firstVar equal to dollar secondVar equal to ten semicolon''' and press '''Enter'''.
  
 
|-
 
|-
|  06.51
+
|  06:51
|  Now to print the values, type
+
|  Now, to print these values, type:
  
 
|-
 
|-
| 06.55
+
| 06:55
| '''print double quote firstVar: dollar firstVar and secondVar: dollar secondVar slash n double quote complete semicolon''' press '''Enter'''.
+
| '''print''' double quote '''firstVar:''' dollar '''firstVar and secondVar:''' dollar '''secondVar''' backslash '''n''' close double quotes  semicolon press '''Enter'''.
  
 
|-
 
|-
| 07.17
+
| 07:17
 
| Now save this file.
 
| Now save this file.
  
 
|-
 
|-
|  07.19
+
|  07:19
|  Now let us add the values in the two variables.
+
|  Now, let us add the values in the two variables.
  
 
|-
 
|-
| 07.23
+
| 07:23
| For this type
+
| For this, type:
  
 
|-
 
|-
| 07.25
+
| 07:25
| '''dollar addition space equal to space dollar firstVar plus space dollar secondVar semicolon'''and Press '''Enter'''.
+
| dollar '''addition''' space equal to space dollar '''firstVar''' space plus space dollar '''secondVar''' semicolon and Press '''Enter'''.
  
 
|-
 
|-
|  07.43
+
|  07:43
 
|  Notice, we haven't declared the variable '''addition'''.
 
|  Notice, we haven't declared the variable '''addition'''.
  
 
|-
 
|-
|  07.47  
+
|  07:47  
|  Once again, to print the value of the  variable '''addition''', type
+
|  Once again, to print the value of the  variable '''addition''', type:
  
 
|-
 
|-
| 07.53
+
| 07:53
| '''print double quote Addition is dollar addition slash n double quote complete semicolon'''
+
| '''print double quote Addition is dollar addition backslash n''' close double quote semicolon.
  
 
|-
 
|-
| 08.05
+
| 08:05
| Save this file
+
| Save this file.
  
 
|-
 
|-
|  08.07
+
|  08:07
|  To compile this file again on terminal type
+
|  To compile this file, again on terminal type:
  
 
|-
 
|-
| 08.12
+
| 08:12
 
| '''perl hyphen c multivar dot pl'''
 
| '''perl hyphen c multivar dot pl'''
  
 
|-
 
|-
| 08.18
+
| 08:18
| There is no syntax error so we can execute the script...
+
| There is no syntax error, so we can '''execute''' the script
  
 
|-
 
|-
|  08.24
+
|  08:24
|   by typing '''perl multivar dot pl'''
+
| by typing '''perl multivar dot pl'''.
 
+
  
 
|-
 
|-
|  08.30
+
|  08:30
|  This will produce an output as highlighted.
+
|  This will produce an '''output''' as highlighted.
 
    
 
    
 
|-
 
|-
|  08.34
+
|  08:34
 
|  Similarly, try subtraction, multiplication and division.
 
|  Similarly, try subtraction, multiplication and division.
 
  
 
|-
 
|-
| 08.39
+
| 08:38
 
| I have written the code here.
 
| I have written the code here.
  
 
|-
 
|-
|  08.41
+
|  08:41
|  Now let us save this file and close it.
+
|  Now, let us '''save''' this file and close it.
  
 
|-
 
|-
|  08.46
+
|  08:46
 
|  Now compile the file by typing
 
|  Now compile the file by typing
  
 
|-
 
|-
| 08.48
+
| 08:48
 
| '''perl hyphen c multivar dot pl'''
 
| '''perl hyphen c multivar dot pl'''
  
 
|-
 
|-
| 08.54
+
| 08:54
| There is no syntax error.
+
| There is no syntax error. So, we can execute the script as '''perl multivar dot pl'''
  
 
|-
 
|-
| 08.55
+
| 09:01
| So we can execute the script as '''perl multivar dot pl'''
+
| On execution, the '''output''' will look like this.
 
+
 
+
|-
+
| 09.02
+
| On execution the output will look like this.
+
  
 
|-
 
|-
|  09.07
+
|  09:06
 
|  This brings us to the end of this tutorial.
 
|  This brings us to the end of this tutorial.
  
 
|-
 
|-
| 09.11
+
| 09:11
| In this tutorial we have learnt,
+
| In this tutorial, we have learnt  
  
 
|-
 
|-
| 09.14
+
| 09:14
| To Declare and Use '''scalar variables''' in '''Perl'''
+
| to declare and use '''scalar variables''' in '''Perl'''.
  
 
|-
 
|-
|  09.18
+
|  09:18
'''Assignment'''
+
|  Assignment:
  
 
|-
 
|-
| 09.20
+
| 09:20
|  Declare a number '''variable'''.  
+
|  Declare a number variable.  
 
|-
 
|-
| 09.22
+
| 09:22
 
| Assign  10 to it.  
 
| Assign  10 to it.  
 
|-
 
|-
| 09.24
+
| 09:24
|  Print the '''variable''' declared.
+
|  Print the variable declared.
 
|-
 
|-
| 09.27
+
| 09:26
 
| Declare 2 '''string variables'''.
 
| Declare 2 '''string variables'''.
 
|-
 
|-
| 09.29
+
| 09:29
 
|  Assign these values to them - “Namaste ” and “India”.  
 
|  Assign these values to them - “Namaste ” and “India”.  
 
|-
 
|-
| 09.34
+
| 09:34
|  Print those '''2  variables''' one after the other.
+
|  Print those two variables one after the other.
 
+
 
+
  
 
|-
 
|-
| 09.38   
+
| 09:38   
|  Watch the video available at the following link  
+
|  Watch the video available at the following link.
  
 
|-
 
|-
| 09.42  
+
| 09:42  
| It summarises the Spoken Tutorial project  
+
| It summarizes the Spoken Tutorial project.
  
 
|-
 
|-
| 09.46
+
| 09:45
| If you do not have good bandwidth, you can  download and watch it  
+
| If you do not have good bandwidth, you can  download and watch it.
  
 
|-
 
|-
|  09.50
+
|  09:50
|  The Spoken Tutorial Project Team  
+
|  The Spoken Tutorial Project Team:
  
 
|-
 
|-
| 09.53
+
| 09:53
| Conducts workshops using spoken tutorials  
+
| Conducts workshops using spoken tutorials.
  
 
|-
 
|-
| 09.57
+
| 09:56
| Gives certificates to those who pass an online  test  
+
| Gives certificates to those who pass an online  test.
  
 
|-
 
|-
| 10.01
+
| 10:01
| For more details, please write to  contact at spoken tutorial dot org  
+
| For more details, please write to  contact at spoken tutorial dot org.
  
 
|-
 
|-
|  10.09
+
|  10:08
|  Spoken Tutorial Project is a part of the Talk to a  Teacher project  
+
|  Spoken Tutorial Project is a part of the Talk to a  Teacher project.
  
 
|-
 
|-
| 10.14  
+
| 10:13  
|  It is supported by the National Mission on  Education through ICT, MHRD, Government of India  
+
|  It is supported by the National Mission on  Education through ICT, MHRD, Government of India.
  
 
|-
 
|-
|  10.23
+
|  10:23
|  More information on this Mission is available  at the following link.
+
|  More information on this mission is available  at the following link.
  
 
|-
 
|-
|  10.29
+
|  10:29
|  Hope you enjoyed this '''Perl''' tutorial. This is Amol Brahmankar signing off.
+
|  Hope you enjoyed this '''Perl''' tutorial. This is Amol Brahmankar, signing off.
  
 
|-
 
|-
|  10.34
+
|  10:34
 
|  Thanks for joining.
 
|  Thanks for joining.
  
 
|}
 
|}

Latest revision as of 12:05, 24 March 2017

Time Narration
00:01 Welcome to the spoken tutorial on Variables in Perl.
00:06 In this tutorial, we will learn about variables in Perl.
00:12 I am using Ubuntu Linux12.04 operating system and
00:18 Perl 5.14.2 that is: Perl revision 5, version 14, and subversion 2.
00:26 I will also be using the gedit Text Editor.
00:30 You can use any text editor of your choice.
00:34 Variables in Perl:
00:37 Variables are used for storing values like text strings, numbers or arrays.
00:44 Once a variable is declared, it can be used over and over again in the script.
00:50 Scalar represents a single value and can store scalars only.
00:56 Scalar variables are declared using $ (dollar) symbol.
01:00 Let us look at variable declaration.
01:03 A variable can be declared as follows: dollar priority semicolon.
01:09 Variable names in Perl can have several formats. Variables must begin with a letter or underscore (_).
01:18 And may contain letters, digits, underscores or a combination of above three.
01:24 Variables declared with CAPITAL letters have special meaning in Perl.
01:30 So, avoid declaring variables using capital letters.
01:34 Now open the Terminal and type: gedit variables dot pl ampersand(&)
01:44 The ampersand will unlock the command prompt on the terminal. Now press Enter.
01:50 This will open the variables.pl file in gedit text editor.
01:56 dot pl (.pl) is the default extension of a Perl file.
02:01 Type the following in the file: dollar priority semicolon and press Enter.
02:10 So we have declared the variable priority.
02:13 You do not need to declare a variable before using it;
02:18 you can just use it into your code.
02:21 Now let us assign a numerical value to the variable priority.
02:25 For this, type: dollar priority space equal to space one semicolon
02:32 and press Enter.
02:34 Next, type:
02:36 print space double quote Value of variable is: dollar priority backslash n close double quote semicolon and press Enter.
02:50 backslash n is the "new line" character.
02:53 Now save this file as variables.pl at any location.
03:02 In my case, it will get saved in home/amol directory. Now save this file.
03:10 Now, let us change the permissions of variables.pl file which we just now created.
03:18 To do so, on the Terminal type, chmod 755 variables dot pl
03:27 This will provide "read", "write" & "execute" rights to the file.
03:32 To compile this Perl script, on the Terminal,
03:36 type: perl hyphen c variables dot pl
03:42 Hyphen c switch compiles the Perl script for any compilation/syntax error.
03:49 Now press Enter.
03:51 This tells us that there is no syntax error in our script.
03:56 Now let us execute the Perl script by typing perl variables dot pl and press Enter.
04:06 The output displayed is as highlighted.
04:10 We can also assign a string value to the variable we declared.
04:15 Switch back to the Text editor window.
04:18 Instead of dollar priority equal to one; type:
04:22 dollar priority equal to in single quotes high;
04:28 Please note that the assignments are evaluated from right to left.
04:34 A scalar can hold data of any type, be it a string, a number.
04:38 Save this file and compile the script once again by typing:
04:45 perl hyphen c variables dot pl now press Enter.
04:51 This tells us that there is no syntax error.
04:55 Execute the script by typing perl variables dot pl and press Enter.
05:03 The output is as shown.
05:07 Now switch back to the Text Editor window.
05:10 You can also use scalars within a double-quoted string as
05:15 dollar priority in double quotes string;
05:19 Save this file and close it.
05:22 Let us learn how to declare multiple variables.
05:27 To do so, open the new file in Text Editor.
05:31 OnTerminal, type: gedit multivar dot pl space ampersand and press Enter.
05:42 This will open "multivar dot pl" file in text editor.
05:48 Now, type:
05:50 dollar firstVar comma dollar secondVar semicolon and press Enter.
06:00 To copy the value of variable dollar firstVar to dollar secondVar, type:
06:07 dollar firstVar space equal to space dollar secondVar semicolon and press Enter.
06:19 All mathematical operations like addition, subtraction, multiplication, division, can be done on these variables.
06:30 Let us see how we can achieve this using Perl.
06:34 Switch to text editor.
06:36 And now let us assign the value 10 to both of these variables by typing,
06:41 dollar firstVar equal to dollar secondVar equal to ten semicolon and press Enter.
06:51 Now, to print these values, type:
06:55 print double quote firstVar: dollar firstVar and secondVar: dollar secondVar backslash n close double quotes semicolon press Enter.
07:17 Now save this file.
07:19 Now, let us add the values in the two variables.
07:23 For this, type:
07:25 dollar addition space equal to space dollar firstVar space plus space dollar secondVar semicolon and Press Enter.
07:43 Notice, we haven't declared the variable addition.
07:47 Once again, to print the value of the variable addition, type:
07:53 print double quote Addition is dollar addition backslash n close double quote semicolon.
08:05 Save this file.
08:07 To compile this file, again on terminal type:
08:12 perl hyphen c multivar dot pl
08:18 There is no syntax error, so we can execute the script
08:24 by typing perl multivar dot pl.
08:30 This will produce an output as highlighted.
08:34 Similarly, try subtraction, multiplication and division.
08:38 I have written the code here.
08:41 Now, let us save this file and close it.
08:46 Now compile the file by typing
08:48 perl hyphen c multivar dot pl
08:54 There is no syntax error. So, we can execute the script as perl multivar dot pl
09:01 On execution, the output will look like this.
09:06 This brings us to the end of this tutorial.
09:11 In this tutorial, we have learnt
09:14 to declare and use scalar variables in Perl.
09:18 Assignment:
09:20 Declare a number variable.
09:22 Assign 10 to it.
09:24 Print the variable declared.
09:26 Declare 2 string variables.
09:29 Assign these values to them - “Namaste ” and “India”.
09:34 Print those two variables one after the other.
09:38 Watch the video available at the following link.
09:42 It summarizes the Spoken Tutorial project.
09:45 If you do not have good bandwidth, you can download and watch it.
09:50 The Spoken Tutorial Project Team:
09:53 Conducts workshops using spoken tutorials.
09:56 Gives certificates to those who pass an online test.
10:01 For more details, please write to contact at spoken tutorial dot org.
10:08 Spoken Tutorial Project is a part of the Talk to a Teacher project.
10:13 It is supported by the National Mission on Education through ICT, MHRD, Government of India.
10:23 More information on this mission is available at the following link.
10:29 Hope you enjoyed this Perl tutorial. This is Amol Brahmankar, signing off.
10:34 Thanks for joining.

Contributors and Content Editors

Gaurav, Madhurig, PoojaMoolya, Sandhya.np14, Sneha