Difference between revisions of "PERL/C2/Variables-in-Perl/English-timed"
From Script | Spoken-Tutorial
PoojaMoolya (Talk | contribs) |
|||
(8 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{| border=1 | {| border=1 | ||
− | + | | '''Time''' | |
− | + | | '''Narration''' | |
|- | |- | ||
− | | 00 | + | | 00:01 |
− | | Welcome to the spoken tutorial on | + | | Welcome to the spoken tutorial on '''Variables in Perl'''. |
|- | |- | ||
− | | 00 | + | | 00:06 |
− | | In this tutorial, we will learn about | + | | In this tutorial, we will learn about '''variables''' in '''Perl'''. |
|- | |- | ||
− | | 00 | + | | 00:12 |
| I am using '''Ubuntu Linux12.04''' operating system and | | I am using '''Ubuntu Linux12.04''' operating system and | ||
|- | |- | ||
− | | 00 | + | | 00:18 |
− | | '''Perl''' '''5.14.2 ''' that is | + | | '''Perl''' '''5.14.2 ''' that is: '''Perl''' revision 5, version 14, and subversion 2. |
− | + | ||
|- | |- | ||
− | | 00 | + | | 00:26 |
| I will also be using the '''gedit Text Editor'''. | | I will also be using the '''gedit Text Editor'''. | ||
|- | |- | ||
− | | 00 | + | | 00:30 |
| You can use any text editor of your choice. | | You can use any text editor of your choice. | ||
|- | |- | ||
− | | 00 | + | | 00:34 |
| '''Variables''' in '''Perl''': | | '''Variables''' in '''Perl''': | ||
|- | |- | ||
− | | 00 | + | | 00:37 |
− | | '''Variables''' are used for storing values | + | | '''Variables''' are used for storing values like text strings, numbers or arrays. |
|- | |- | ||
− | | 00 | + | | 00:44 |
− | | Once a | + | | Once a variable is declared, it can be used over and over again in the script. |
|- | |- | ||
− | | 00 | + | | 00:50 |
| '''Scalar''' represents a single value and can store '''scalars''' only. | | '''Scalar''' represents a single value and can store '''scalars''' only. | ||
|- | |- | ||
− | | 00 | + | | 00:56 |
− | | '''Scalar | + | | '''Scalar''' variables are declared using $ (dollar) symbol. |
|- | |- | ||
− | | 01 | + | | 01:00 |
− | | Let us look at ''' | + | | Let us look at '''variable''' declaration. |
|- | |- | ||
− | | 01 | + | | 01:03 |
− | | A | + | | A variable can be declared as follows: '''dollar priority semicolon'''. |
− | + | ||
|- | |- | ||
− | | 01 | + | | 01:09 |
− | | '''Variable''' names in '''Perl''' can have several formats. | + | | '''Variable''' names in '''Perl''' can have several formats. Variables must begin with a letter or '''underscore''' (_). |
|- | |- | ||
− | | 01 | + | | 01:18 |
− | | And may | + | | And may contain letters, digits, '''underscores''' or a combination of above three. |
|- | |- | ||
− | | 01 | + | | 01:24 |
− | | | + | | Variables declared with CAPITAL letters have special meaning in '''Perl.''' |
|- | |- | ||
− | | 01 | + | | 01:30 |
− | | So avoid declaring | + | | So, avoid declaring variables using capital letters. |
|- | |- | ||
− | | 01 | + | | 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 | + | | 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 | + | | 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 | + | | 01:56 |
− | | '''dot pl '''is the default extension of a '''Perl''' file. | + | | '''dot pl''' (.pl) is the '''default''' '''extension''' of a '''Perl''' file. |
|- | |- | ||
− | | 02 | + | | 02:01 |
− | | Type the following in the file | + | | Type the following in the file: '''dollar priority semicolon''' and press '''Enter'''. |
|- | |- | ||
− | | 02 | + | | 02:10 |
| So we have declared the '''variable priority'''. | | So we have declared the '''variable priority'''. | ||
|- | |- | ||
− | | 02 | + | | 02:13 |
− | | You do not need to declare a | + | | You do not need to declare a variable before using it; |
|- | |- | ||
− | | 02 | + | | 02:18 |
| you can just use it into your code. | | you can just use it into your code. | ||
|- | |- | ||
− | | 02 | + | | 02:21 |
− | | Now let us assign a numerical value to the ''' | + | | Now let us assign a numerical value to the variable '''priority'''. |
|- | |- | ||
− | | 02 | + | | 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 | + | | 02:32 |
| and press '''Enter'''. | | and press '''Enter'''. | ||
|- | |- | ||
− | | 02 | + | | 02:34 |
− | | Next, type | + | | Next, type: |
|- | |- | ||
− | | 02 | + | | 02:36 |
− | | '''print space double quote Value of variable is: dollar priority | + | | '''print''' space double quote '''Value of variable is:''' dollar '''priority''' backslash '''n''' close double quote semicolon and press '''Enter'''. |
|- | |- | ||
− | | 02 | + | | 02:50 |
− | | ''' | + | | '''backslash n''' is the "new line" character. |
|- | |- | ||
− | | 02 | + | | 02:53 |
− | | Now save this file as '''variables.pl''' at any location. | + | | Now '''save''' this file as '''variables.pl''' at any location. |
|- | |- | ||
− | | 03 | + | | 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 | + | | 03:10 |
− | | Now, let us change the permissions of '''variables.pl''' | + | | Now, let us change the permissions of '''variables.pl''' file which we just now created. |
|- | |- | ||
− | | 03 | + | | 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 | + | | 03:27 |
− | | This will provide read, write & execute rights to the file. | + | | This will provide "read", "write" & "execute" rights to the file. |
|- | |- | ||
− | | 03 | + | | 03:32 |
− | | To compile this '''Perl''' script, on the '''Terminal''' | + | | To compile this '''Perl''' script, on the '''Terminal''', |
|- | |- | ||
− | | 03 | + | | 03:36 |
− | | type | + | | type: '''perl hyphen c variables dot pl''' |
|- | |- | ||
− | | 03 | + | | 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 | + | | 03:49 |
− | | Now press '''Enter''' | + | | Now press '''Enter'''. |
|- | |- | ||
− | | 03 | + | | 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 | + | | 03:56 |
− | | Now let | + | | Now let us execute the '''Perl''' script by typing '''perl variables dot pl''' and press '''Enter'''. |
|- | |- | ||
− | | 04 | + | | 04:06 |
| The output displayed is as highlighted. | | The output displayed is as highlighted. | ||
|- | |- | ||
− | | 04 | + | | 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 | + | | 04:15 |
| Switch back to the Text editor window. | | Switch back to the Text editor window. | ||
|- | |- | ||
− | | 04 | + | | 04:18 |
− | | Instead of '''dollar priority equal to one;''' | + | | Instead of '''dollar priority equal to one;''' type: |
|- | |- | ||
− | | 04 | + | | 04:22 |
− | | '''dollar priority equal to in single | + | | '''dollar priority''' equal to in single quotes '''high'''; |
|- | |- | ||
− | | 04 | + | | 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 | + | | 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 | + | | 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 | + | | 04:45 |
| '''perl hyphen c variables dot pl''' now press '''Enter'''. | | '''perl hyphen c variables dot pl''' now press '''Enter'''. | ||
|- | |- | ||
− | | 04 | + | | 04:51 |
| This tells us that there is no syntax error. | | This tells us that there is no syntax error. | ||
− | |||
|- | |- | ||
− | | 04 | + | | 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 | + | | 05:03 |
− | | The output is as shown. | + | | The '''output''' is as shown. |
|- | |- | ||
− | | 05 | + | | 05:07 |
− | | Now switch back to the Text Editor window. | + | | Now switch back to the '''Text Editor''' '''window'''. |
− | + | ||
|- | |- | ||
− | | 05 | + | | 05:10 |
− | | You can also use '''scalars''' within a double-quoted ''' | + | | You can also use '''scalars''' within a double-quoted '''string''' as |
|- | |- | ||
− | | 05 | + | | 05:15 |
− | | '''dollar priority in double | + | | '''dollar priority''' in double quotes '''string'''; |
− | + | ||
|- | |- | ||
− | | 05 | + | | 05:19 |
− | | Save this file and close it. | + | | '''Save''' this file and close it. |
|- | |- | ||
− | | 05 | + | | 05:22 |
− | | | + | | Let us learn how to declare multiple variables. |
|- | |- | ||
− | | 05 | + | | 05:27 |
− | | To do so open the new file in Text Editor. | + | | To do so, open the new file in Text Editor. |
|- | |- | ||
− | | 05 | + | | 05:31 |
− | | | + | | On'''Terminal''', type: '''gedit multivar dot pl space ampersand''' and press '''Enter'''. |
− | + | ||
|- | |- | ||
− | | 05 | + | | 05:42 |
− | | This will open | + | | This will open "multivar dot pl" file in text editor. |
|- | |- | ||
− | | 05 | + | | 05:48 |
− | | Now | + | | Now, type: |
|- | |- | ||
− | | 05 | + | | 05:50 |
| '''dollar firstVar comma dollar secondVar semicolon''' and press '''Enter'''. | | '''dollar firstVar comma dollar secondVar semicolon''' and press '''Enter'''. | ||
|- | |- | ||
− | | 06 | + | | 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 | + | | 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 | + | | 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 | + | | 06:30 |
| Let us see how we can achieve this using '''Perl'''. | | Let us see how we can achieve this using '''Perl'''. | ||
|- | |- | ||
− | | 06 | + | | 06:34 |
− | | Switch to text editor. | + | | Switch to '''text editor'''. |
|- | |- | ||
− | | 06 | + | | 06:36 |
| And now let us assign the value '''10''' to both of these variables by typing, | | And now let us assign the value '''10''' to both of these variables by typing, | ||
|- | |- | ||
− | | 06 | + | | 06:41 |
− | | '''dollar firstVar equal to dollar secondVar equal to ten semicolon''' | + | | '''dollar firstVar equal to dollar secondVar equal to ten semicolon''' and press '''Enter'''. |
|- | |- | ||
− | | 06 | + | | 06:51 |
− | | Now to print these values, type | + | | Now, to print these values, type: |
|- | |- | ||
− | | 06 | + | | 06:55 |
− | | '''print double quote firstVar: dollar firstVar and secondVar: dollar secondVar | + | | '''print''' double quote '''firstVar:''' dollar '''firstVar and secondVar:''' dollar '''secondVar''' backslash '''n''' close double quotes semicolon press '''Enter'''. |
|- | |- | ||
− | | 07 | + | | 07:17 |
| Now save this file. | | Now save this file. | ||
|- | |- | ||
− | | 07 | + | | 07:19 |
− | | Now let us add the values in the two variables. | + | | Now, let us add the values in the two variables. |
|- | |- | ||
− | | 07 | + | | 07:23 |
− | | For this type | + | | For this, type: |
|- | |- | ||
− | | 07 | + | | 07:25 |
− | | ''' | + | | dollar '''addition''' space equal to space dollar '''firstVar''' space plus space dollar '''secondVar''' semicolon and Press '''Enter'''. |
|- | |- | ||
− | | 07 | + | | 07:43 |
| Notice, we haven't declared the variable '''addition'''. | | Notice, we haven't declared the variable '''addition'''. | ||
|- | |- | ||
− | | 07 | + | | 07:47 |
− | | Once again, to print the value of the variable | + | | Once again, to print the value of the variable '''addition''', type: |
|- | |- | ||
− | | 07 | + | | 07:53 |
− | | '''print double quote Addition is dollar addition | + | | '''print double quote Addition is dollar addition backslash n''' close double quote semicolon. |
|- | |- | ||
− | | 08 | + | | 08:05 |
− | | Save this file | + | | Save this file. |
|- | |- | ||
− | | 08 | + | | 08:07 |
− | | To compile this file again on terminal type | + | | To compile this file, again on terminal type: |
|- | |- | ||
− | | 08 | + | | 08:12 |
| '''perl hyphen c multivar dot pl''' | | '''perl hyphen c multivar dot pl''' | ||
|- | |- | ||
− | | 08 | + | | 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 | + | | 08:24 |
− | | | + | | by typing '''perl multivar dot pl'''. |
− | + | ||
|- | |- | ||
− | | 08 | + | | 08:30 |
− | | This will produce an output as highlighted. | + | | This will produce an '''output''' as highlighted. |
|- | |- | ||
− | | 08 | + | | 08:34 |
| Similarly, try subtraction, multiplication and division. | | Similarly, try subtraction, multiplication and division. | ||
− | |||
|- | |- | ||
− | | 08 | + | | 08:38 |
| I have written the code here. | | I have written the code here. | ||
|- | |- | ||
− | | 08 | + | | 08:41 |
− | | Now let us save this file and close it. | + | | Now, let us '''save''' this file and close it. |
|- | |- | ||
− | | 08 | + | | 08:46 |
| Now compile the file by typing | | Now compile the file by typing | ||
|- | |- | ||
− | | 08 | + | | 08:48 |
| '''perl hyphen c multivar dot pl''' | | '''perl hyphen c multivar dot pl''' | ||
|- | |- | ||
− | | 08 | + | | 08:54 |
− | | There is no syntax error. | + | | 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 | + | | 09:06 |
| This brings us to the end of this tutorial. | | This brings us to the end of this tutorial. | ||
|- | |- | ||
− | | 09 | + | | 09:11 |
− | | In this tutorial we have learnt | + | | In this tutorial, we have learnt |
|- | |- | ||
− | | 09 | + | | 09:14 |
− | | | + | | to declare and use '''scalar variables''' in '''Perl'''. |
|- | |- | ||
− | | 09 | + | | 09:18 |
− | | | + | | Assignment: |
|- | |- | ||
− | | 09 | + | | 09:20 |
− | | Declare a number | + | | Declare a number variable. |
|- | |- | ||
− | | 09 | + | | 09:22 |
| Assign 10 to it. | | Assign 10 to it. | ||
|- | |- | ||
− | | 09 | + | | 09:24 |
− | | Print the | + | | Print the variable declared. |
|- | |- | ||
− | | 09 | + | | 09:26 |
| Declare 2 '''string variables'''. | | Declare 2 '''string variables'''. | ||
|- | |- | ||
− | | 09 | + | | 09:29 |
| Assign these values to them - “Namaste ” and “India”. | | Assign these values to them - “Namaste ” and “India”. | ||
|- | |- | ||
− | | 09 | + | | 09:34 |
− | | Print those | + | | Print those two variables one after the other. |
− | + | ||
− | + | ||
|- | |- | ||
− | | 09 | + | | 09:38 |
− | | Watch the video available at the following link | + | | Watch the video available at the following link. |
|- | |- | ||
− | | 09 | + | | 09:42 |
− | | It | + | | It summarizes the Spoken Tutorial project. |
|- | |- | ||
− | | 09 | + | | 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 | + | | 09:50 |
− | | The Spoken Tutorial Project Team | + | | The Spoken Tutorial Project Team: |
|- | |- | ||
− | | 09 | + | | 09:53 |
− | | Conducts workshops using spoken tutorials | + | | Conducts workshops using spoken tutorials. |
|- | |- | ||
− | | 09 | + | | 09:56 |
− | | Gives certificates to those who pass an online test | + | | Gives certificates to those who pass an online test. |
|- | |- | ||
− | | 10 | + | | 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 | + | | 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 | + | | 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 | + | | 10:23 |
− | | More information on this | + | | More information on this mission is available at the following link. |
|- | |- | ||
− | | 10 | + | | 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 | + | | 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. |