Difference between revisions of "PERL/C2/Comments-in-Perl/English-timed"
From Script | Spoken-Tutorial
Sandhya.np14 (Talk | contribs) |
Sandhya.np14 (Talk | contribs) |
||
| Line 48: | Line 48: | ||
|- | |- | ||
| 00:48 | | 00:48 | ||
| − | |* ''' Multi Line'''. | + | |* ''' Multi-Line'''. |
|- | |- | ||
|00:49 | |00:49 | ||
| Line 207: | Line 207: | ||
|- | |- | ||
| 04:52 | | 04:52 | ||
| − | | | + | | Please note, there should not be any leading or trailing space(s) before '''= to''' (equal to sign) and after the '''head''', '''cut''', '''begin''' or '''end''' word. |
|- | |- | ||
|05:02 | |05:02 | ||
| − | | | + | | Open the '''Terminal''' once again. |
|- | |- | ||
| 05:05 | | 05:05 | ||
| − | |And Type - ''' | + | |And Type - ''' gedit commentsExample dot pl space &''' and press '''Enter'''. |
|- | |- | ||
| Line 223: | Line 223: | ||
|- | |- | ||
|05:19 | |05:19 | ||
| − | |Here I am declaring two variables '''firstNum '''and '''secondNum '''and I am assigning some values to them. | + | |Here, I am declaring two variables '''firstNum '''and '''secondNum '''and I am assigning some values to them. |
|- | |- | ||
| Line 231: | Line 231: | ||
|- | |- | ||
|05:32 | |05:32 | ||
| − | |Now I added these two numbers and assign the value to a third variable named addition. | + | |Now I added these two numbers and assign the value to a third variable named '''addition'''. |
|- | |- | ||
|05:39 | |05:39 | ||
| − | |Next I want to print the value using print command. | + | |Next, I want to print the value using print command. |
|- | |- | ||
| Line 243: | Line 243: | ||
|- | |- | ||
|05:49 | |05:49 | ||
| − | |On terminal type '''perl hyphen c commentsExample dot pl''', press '''Enter.''' | + | |On terminal, type: '''perl hyphen c commentsExample dot pl''', press '''Enter.''' |
|- | |- | ||
|05:57 | |05:57 | ||
| − | |There is no syntax error | + | |There is no syntax error. |
|- | |- | ||
|05:59 | |05:59 | ||
| − | |So execute the script by typing | + | |So, execute the script by typing |
|- | |- | ||
|06:01 | |06:01 | ||
| − | |'''perl commentsExample dot pl''' press | + | |'''perl commentsExample dot pl''' press '''Enter.''' |
|- | |- | ||
|06:07 | |06:07 | ||
| − | | It will show the following output. '''Addition is 30''' | + | | It will show the following output. '''Addition is 30'''. |
|- | |- | ||
| Line 267: | Line 267: | ||
|- | |- | ||
|06:16 | |06:16 | ||
| − | |Here we learnt | + | |Here we learnt to add comments in '''Perl'''. |
|- | |- | ||
|06:19 | |06:19 | ||
|Write a perl script to find square of a number. | |Write a perl script to find square of a number. | ||
| + | |||
|- | |- | ||
|06:23 | |06:23 | ||
| − | |Explain the functionality of the code written using | + | |Explain the functionality of the code written using '''single line comment''' & '''multiline Comment'''. |
|- | |- | ||
| 06:30 | | 06:30 | ||
| − | | Watch the video available at the following link | + | | Watch the video available at the following link. |
|- | |- | ||
|06:34 | |06:34 | ||
| − | |It | + | |It summarizes the Spoken Tutorial project. |
|- | |- | ||
|06:37 | |06:37 | ||
| − | |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. |
|- | |- | ||
| 06:42 | | 06:42 | ||
| − | | | + | |The Spoken Tutorial Project Team: |
|- | |- | ||
|06:44 | |06:44 | ||
| − | |Conducts workshops using spoken tutorials | + | |Conducts workshops using spoken tutorials. |
|- | |- | ||
|06:48 | |06:48 | ||
| − | |Gives certificates to those who pass an online test | + | |Gives certificates to those who pass an online test. |
|- | |- | ||
|06:51 | |06:51 | ||
| − | |For more details, please write to contact at spoken hyphen tutorial dot org | + | |For more details, please write to contact at spoken hyphen tutorial dot org. |
|- | |- | ||
| 06:58 | | 06:58 | ||
| − | | 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. |
|- | |- | ||
|07:03 | |07:03 | ||
| − | |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. |
|- | |- | ||
|07:11 | |07:11 | ||
| − | |More information on this | + | |More information on this mission is available at the following link. |
|- | |- | ||
| 07:15 | | 07:15 | ||
| − | | Hope you enjoyed this '''Perl''' tutorial. This is Amol Brahmankar signing off. | + | | Hope you enjoyed this '''Perl''' tutorial. This is Amol Brahmankar, signing off. |
Thanks for joining. | Thanks for joining. | ||
|} | |} | ||
Revision as of 15:29, 7 May 2015
| Time | Narration |
|---|---|
| 00:00 | Welcome to the spoken tutorial on Comments in Perl. |
| 00:05 | In this tutorial, we will learn about |
| 00:08 | comments in Perl. |
| 00:10 | I am using Ubuntu Linux 12.04 operating system and Perl 5.14.2 |
| 00:18 | that is, Perl revision 5 version 14 and subversion 2. |
| 00:23 | I will also be using the gedit Text Editor. |
| 00:27 | You can use any text editor of your choice. |
| 00:31 | You should have basic knowledge of compiling, executing and variables in Perl. |
| 00:37 | If not, please go through the relevant spoken tutorials on the spoken tutorial website. |
| 00:43 | Commenting a piece of code in Perl can be done in two ways: |
| 00:47 | * Single Line |
| 00:48 | * Multi-Line. |
| 00:49 | This type of comment is used when user wants to comment a single line of code or |
| 00:55 | to add one liner text to explain the functionality of a piece of code. |
| 01:01 | This type of comment starts with the symbol # (hash). |
| 01:05 | Here is a demo. Let us open a new file in the Text Editor. |
| 01:11 | Open the Terminal and type - gedit comments dot pl space & |
| 01:19 | Once again reminding you that the ampersand is used to free the command prompt in the terminal, now press Enter. |
| 01:27 | Now type the following commands. |
| 01:29 | hash Declaring count variable press Enter. |
| 01:37 | dollar count space equal to space 1 semicolon press Enter. |
| 01:45 | print space double quotes Count is dollar count slash n double quotes complete semicolon space hash Prints Count is 1 |
| 02:03 | Now save this file by pressing Ctrl S and execute the Perl script. |
| 02:08 | Switch to the Terminal, and type perl hyphen c comments dot pl and press Enter. |
| 02:18 | This tells us that there is no syntax error. |
| 02:21 | Now type: perl comments dot pl and press Enter. |
| 02:28 | It will show the following output - Count is 1 |
| 02:33 | Let us switch back to gedit. |
| 02:36 | In gedit, go to the first line and press Enter. |
| 02:40 | Go back to the first line and type the following command. |
| 02:44 | Hash exclamation mark slash usr slash bin slash perl |
| 02:52 | This line in Perl is called as shebang line and is the first line in a Perl program. |
| 02:59 | It tells where to find the Perl Interpreter. |
| 03:03 | Note: Though this line starts with hash symbol, it will not be considered as a single line comment by Perl. |
| 03:11 | Now let us look at multiline comments. |
| 03:13 | Multi Line: This type of comment is used |
| 03:17 | when user wants to comment a piece of code or to add description/usage of piece of code. |
| 03:25 | This type of comment starts with the symbol equal to head and ends with equal to cut. |
| 03:33 | Let's switch back to gedit and type the following in the comments dot pl file. |
| 03:39 | At the end of file, type: equal to head, press Enter. |
| 03:45 | print space double quote count variable is used for counting purpose double quote complete press Enter. |
| 03:59 | equal to cut |
| 04:01 | Save the file, close it and execute the Perl script. |
| 04:05 | On the Terminal, type: perl hyphen c comments dot pl and press Enter. |
| 04:13 | No syntax error. |
| 04:15 | So let us execute it, perl comments dot pl |
| 04:21 | It will show the same output as before. Count is 1. |
| 04:27 | It does not print the sentence “count variable is used for counting purpose”. |
| 04:32 | This is because we commented the portion using equal to head and equal to cut. |
| 04:40 | You can either use =head =cut or =begin =end. |
| 04:48 | These are not the special keywords used by Perl. |
| 04:52 | Please note, there should not be any leading or trailing space(s) before = to (equal to sign) and after the head, cut, begin or end word. |
| 05:02 | Open the Terminal once again. |
| 05:05 | And Type - gedit commentsExample dot pl space & and press Enter. |
| 05:15 | Type the following commands as shown on the screen. |
| 05:19 | Here, I am declaring two variables firstNum and secondNum and I am assigning some values to them. |
| 05:28 | Then I have commented this portion here. |
| 05:32 | Now I added these two numbers and assign the value to a third variable named addition. |
| 05:39 | Next, I want to print the value using print command. |
| 05:44 | Save the file and execute the Perl script on the Terminal. |
| 05:49 | On terminal, type: perl hyphen c commentsExample dot pl, press Enter. |
| 05:57 | There is no syntax error. |
| 05:59 | So, execute the script by typing |
| 06:01 | perl commentsExample dot pl press Enter. |
| 06:07 | It will show the following output. Addition is 30. |
| 06:12 | This brings us to the end of this tutorial. |
| 06:16 | Here we learnt to add comments in Perl. |
| 06:19 | Write a perl script to find square of a number. |
| 06:23 | Explain the functionality of the code written using single line comment & multiline Comment. |
| 06:30 | Watch the video available at the following link. |
| 06:34 | It summarizes the Spoken Tutorial project. |
| 06:37 | If you do not have good bandwidth, you can download and watch it. |
| 06:42 | The Spoken Tutorial Project Team: |
| 06:44 | Conducts workshops using spoken tutorials. |
| 06:48 | Gives certificates to those who pass an online test. |
| 06:51 | For more details, please write to contact at spoken hyphen tutorial dot org. |
| 06:58 | Spoken Tutorial Project is a part of the Talk to a Teacher project. |
| 07:03 | It is supported by the National Mission on Education through ICT, MHRD, Government of India. |
| 07:11 | More information on this mission is available at the following link. |
| 07:15 | Hope you enjoyed this Perl tutorial. This is Amol Brahmankar, signing off.
Thanks for joining. |