Difference between revisions of "PERL/C2/Comments-in-Perl/English-timed"
From Script | Spoken-Tutorial
PoojaMoolya (Talk | contribs) |
|||
Line 1: | Line 1: | ||
{| border=1 | {| border=1 | ||
− | ! | + | ! '''Time''' |
− | ! | + | ! '''Narration''' |
|- | |- | ||
− | |00 | + | |00:00 |
| Welcome to the spoken tutorial on Comments in '''Perl'''. | | Welcome to the spoken tutorial on Comments in '''Perl'''. | ||
|- | |- | ||
− | | 00 | + | | 00:05 |
| In this tutorial, we will learn about | | In this tutorial, we will learn about | ||
|- | |- | ||
− | |00 | + | |00:08 |
|Comments in '''Perl''' | |Comments in '''Perl''' | ||
|- | |- | ||
− | |00 | + | |00:10 |
|I am using '''Ubuntu Linux12.04''' operating system and '''Perl''' '''5.14.2 ''' | |I am using '''Ubuntu Linux12.04''' operating system and '''Perl''' '''5.14.2 ''' | ||
|- | |- | ||
− | |00 | + | |00:18 |
|that is, '''Perl''' revision 5 version 14 and subversion 2 | |that is, '''Perl''' revision 5 version 14 and subversion 2 | ||
|- | |- | ||
− | |00 | + | |00:23 |
|I will also be using the '''gedit Text Editor'''. | |I will also be using the '''gedit Text Editor'''. | ||
|- | |- | ||
− | |00 | + | |00:27 |
|You can use any text editor of your choice. | |You can use any text editor of your choice. | ||
|- | |- | ||
− | |00 | + | |00:31 |
|You should have Basic knowledge of Compiling, Executing and Variables in Perl | |You should have Basic knowledge of Compiling, Executing and Variables in Perl | ||
|- | |- | ||
− | |00 | + | |00:37 |
|If not, please go through the relevant spoken tutorials on the spoken tutorial website | |If not, please go through the relevant spoken tutorials on the spoken tutorial website | ||
|- | |- | ||
− | | 00 | + | | 00:43 |
|Commenting a piece of code in '''Perl''' can be done in two ways: | |Commenting a piece of code in '''Perl''' can be done in two ways: | ||
|- | |- | ||
− | | 00 | + | | 00:47 |
|'''Single Line''' | |'''Single Line''' | ||
|- | |- | ||
− | | 00 | + | | 00:48 |
| ''' Multi Line''' | | ''' Multi Line''' | ||
|- | |- | ||
− | |00 | + | |00:49 |
|This type of comment is used when user wants to comment a single line of code or | |This type of comment is used when user wants to comment a single line of code or | ||
|- | |- | ||
− | |00 | + | |00:55 |
| to add one liner text to explain the functionality of a piece of code | | to add one liner text to explain the functionality of a piece of code | ||
|- | |- | ||
− | |01 | + | |01:01 |
|This type of comment starts with the symbol ''' # (hash) '''. | |This type of comment starts with the symbol ''' # (hash) '''. | ||
|- | |- | ||
− | | 01 | + | | 01:05 |
|Here is a demo. Let us open a new file in the Text Editor. | |Here is a demo. Let us open a new file in the Text Editor. | ||
|- | |- | ||
− | | 01 | + | | 01:11 |
| Open the '''Terminal''' and type - '''gedit comments dot pl space &''' | | Open the '''Terminal''' and type - '''gedit comments dot pl space &''' | ||
|- | |- | ||
− | | 01 | + | | 01:19 |
|Once again, reminding you that the '''ampersand''' is used to free the '''command prompt''' in the '''terminal''' and press enter. | |Once again, reminding you that the '''ampersand''' is used to free the '''command prompt''' in the '''terminal''' and press enter. | ||
|- | |- | ||
− | |01 | + | |01:27 |
|Now type the following commands. | |Now type the following commands. | ||
|- | |- | ||
− | |01 | + | |01:29 |
|'''hash Declaring count variable''' 'press '''Enter''' | |'''hash Declaring count variable''' 'press '''Enter''' | ||
|- | |- | ||
− | |01 | + | |01:37 |
|'''dollar count space equal to space 1 semicolon''' '''press enter''' | |'''dollar count space equal to space 1 semicolon''' '''press enter''' | ||
|- | |- | ||
− | |01 | + | |01:45 |
|'''print space double quotes Count is dollar count slash n''' close double quote '''semicolon space hash prints Count is 1''' | |'''print space double quotes Count is dollar count slash n''' close double quote '''semicolon space hash prints Count is 1''' | ||
|- | |- | ||
− | |02 | + | |02:03 |
| Now Save this file by pressing ctlr S and execute the '''Perl''' script. | | Now Save this file by pressing ctlr S and execute the '''Perl''' script. | ||
|- | |- | ||
− | | 02 | + | | 02:08 |
| Switch to the '''Terminal''', and type '''perl hyphen c comments dot pl''' and press '''Enter.''' | | Switch to the '''Terminal''', and type '''perl hyphen c comments dot pl''' and press '''Enter.''' | ||
|- | |- | ||
− | |02 | + | |02:18 |
|This tells us that there is no syntax error | |This tells us that there is no syntax error | ||
|- | |- | ||
− | | 02 | + | | 02:21 |
|Now type '''perl comments dot pl''' and press '''Enter.''' | |Now type '''perl comments dot pl''' and press '''Enter.''' | ||
|- | |- | ||
− | |02 | + | |02:28 |
| It will show the following output - '''Count is 1''' | | It will show the following output - '''Count is 1''' | ||
|- | |- | ||
− | | 02 | + | | 02:33 |
|Let us switch back to '''gedit'''. | |Let us switch back to '''gedit'''. | ||
|- | |- | ||
− | | 02 | + | | 02:36 |
|In '''gedit''', go to the first line and press enter. | |In '''gedit''', go to the first line and press enter. | ||
|- | |- | ||
− | |02 | + | |02:40 |
|Go back to the first line and type the following command. | |Go back to the first line and type the following command. | ||
|- | |- | ||
− | | 02 | + | | 02:44 |
|'''Hash exclamation mark slash usr slash bin slash perl''' | |'''Hash exclamation mark slash usr slash bin slash perl''' | ||
|- | |- | ||
− | | 02 | + | | 02:52 |
|This line in '''Perl''' is called as a '''shebang''' '''line''' and is the first line in a '''Perl '''program. | |This line in '''Perl''' is called as a '''shebang''' '''line''' and is the first line in a '''Perl '''program. | ||
|- | |- | ||
− | |02 | + | |02:59 |
|It tells where to find the '''Perl Interpreter'''. | |It tells where to find the '''Perl Interpreter'''. | ||
|- | |- | ||
− | |03 | + | |03:03 |
|'''Note:''' Though this line starts with hash symbol, it will not be considered as a single line comment by '''Perl'''. | |'''Note:''' Though this line starts with hash symbol, it will not be considered as a single line comment by '''Perl'''. | ||
|- | |- | ||
− | |03 | + | |03:11 |
|Now let us look at multiline comments | |Now let us look at multiline comments | ||
|- | |- | ||
− | | 03 | + | | 03:13 |
|'''Multi Line''' This type of comment is used | |'''Multi Line''' This type of comment is used | ||
|- | |- | ||
− | |03 | + | |03:17 |
|when user wants to comment a piece of code or to add description/usage of piece of code | |when user wants to comment a piece of code or to add description/usage of piece of code | ||
|- | |- | ||
− | |03 | + | |03:25 |
|This type of comment starts with the symbol '''equal to head''' and ends with '''equal to cut''' | |This type of comment starts with the symbol '''equal to head''' and ends with '''equal to cut''' | ||
|- | |- | ||
− | | 03 | + | | 03:33 |
|Lets switch back to '''gedit''' and type the following in the '''comments dot pl '''file | |Lets switch back to '''gedit''' and type the following in the '''comments dot pl '''file | ||
|- | |- | ||
− | |03 | + | |03:39 |
|at the end of file type '''equal to head''', press '''Enter''' | |at the end of file type '''equal to head''', press '''Enter''' | ||
|- | |- | ||
− | |03 | + | |03:45 |
|'''print space double quote count variable is used for counting purpose''' close double quote press enter. | |'''print space double quote count variable is used for counting purpose''' close double quote press enter. | ||
|- | |- | ||
− | |03 | + | |03:59 |
|'''equal to cut''' | |'''equal to cut''' | ||
|- | |- | ||
− | | 04 | + | | 04:01 |
| Save the file, close it and execute the '''Perl''' script. | | Save the file, close it and execute the '''Perl''' script. | ||
|- | |- | ||
− | | 04 | + | | 04:05 |
| On the '''Terminal''', type '''perl hyphen c comments dot pl''' and press '''Enter'''. | | On the '''Terminal''', type '''perl hyphen c comments dot pl''' and press '''Enter'''. | ||
|- | |- | ||
− | |04 | + | |04:13 |
|No syntax error | |No syntax error | ||
|- | |- | ||
− | | 04 | + | | 04:15 |
| so let us execute it '''perl comments dot pl''' | | so let us execute it '''perl comments dot pl''' | ||
|- | |- | ||
− | | 04 | + | | 04:21 |
| It will show the same output as before. '''Count is 1''' | | It will show the same output as before. '''Count is 1''' | ||
|- | |- | ||
− | |04 | + | |04:27 |
| It does not print the sentence '''“count variable is used for counting purpose”''' | | It does not print the sentence '''“count variable is used for counting purpose”''' | ||
|- | |- | ||
− | |04 | + | |04:32 |
| This is because we commented the portion using '''equal to head''' and '''equal to cut''' | | This is because we commented the portion using '''equal to head''' and '''equal to cut''' | ||
|- | |- | ||
− | |04 | + | |04:40 |
| You can either use '''=head =cut''' or '''=begin =end.''' | | You can either use '''=head =cut''' or '''=begin =end.''' | ||
|- | |- | ||
− | |04 | + | |04:48 |
|These are not the special keywords used by '''Perl'''. | |These are not the special keywords used by '''Perl'''. | ||
|- | |- | ||
− | | 04 | + | | 04:52 |
| '''Please note''' there should not be any leading or trailing space(s) before '''= to''' sign and after the '''head''', '''cut''', '''begin''' or '''end''' word. | | '''Please note''' there should not be any leading or trailing space(s) before '''= to''' sign and after the '''head''', '''cut''', '''begin''' or '''end''' word. | ||
|- | |- | ||
− | |05 | + | |05:02 |
| Open the '''Terminal''' once again. | | Open the '''Terminal''' once again. | ||
|- | |- | ||
− | | 05 | + | | 05:05 |
|And Type - ''' gedit commentsExample dot pl space &''' and press '''Enter'''. | |And Type - ''' gedit commentsExample dot pl space &''' and press '''Enter'''. | ||
|- | |- | ||
− | | 05 | + | | 05:15 |
| Type the following commands as shown on the screen. | | Type the following commands as shown on the screen. | ||
|- | |- | ||
− | |05 | + | |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. | ||
|- | |- | ||
− | |05 | + | |05:28 |
|Then I have commented this portion here. | |Then I have commented this portion here. | ||
|- | |- | ||
− | |05 | + | |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 | + | |05:39 |
|Next I want to print the value using print command. | |Next I want to print the value using print command. | ||
|- | |- | ||
− | |05 | + | |05:44 |
| Save the file and execute the '''Perl''' script on the '''Terminal'''. | | Save the file and execute the '''Perl''' script on the '''Terminal'''. | ||
|- | |- | ||
− | |05 | + | |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 | + | |05:57 |
|There is no syntax error | |There is no syntax error | ||
|- | |- | ||
− | |05 | + | |05:59 |
|So execute the script by typing | |So execute the script by typing | ||
|- | |- | ||
− | |06 | + | |06:01 |
|'''perl commentsExample dot pl''' press enter | |'''perl commentsExample dot pl''' press enter | ||
|- | |- | ||
− | | | + | |06:07 |
| It will show the following output. '''Addition is 30''' | | It will show the following output. '''Addition is 30''' | ||
|- | |- | ||
− | | 06 | + | | 06:12 |
| This brings us to the end of this tutorial. | | This brings us to the end of this tutorial. | ||
|- | |- | ||
− | |06 | + | |06:16 |
|Here we learnt, To Add Comments in '''Perl''' | |Here we learnt, To Add Comments in '''Perl''' | ||
|- | |- | ||
− | |06 | + | |06:19 |
|Write a perl script to find square of a number. | |Write a perl script to find square of a number. | ||
|- | |- | ||
− | |06 | + | |06:23 |
|Explain the functionality of the code written using: Single Line Comment & Mutli Line Comment. | |Explain the functionality of the code written using: Single Line Comment & Mutli Line Comment. | ||
|- | |- | ||
− | | 06 | + | | 06:30 |
| Watch the video available at the following link | | Watch the video available at the following link | ||
|- | |- | ||
− | |06 | + | |06:34 |
|It summarises the Spoken Tutorial project | |It summarises the Spoken Tutorial project | ||
|- | |- | ||
− | |06 | + | |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 | + | | 06:42 |
| The Spoken Tutorial Project Team | | The Spoken Tutorial Project Team | ||
|- | |- | ||
− | |06 | + | |06:44 |
|Conducts workshops using spoken tutorials | |Conducts workshops using spoken tutorials | ||
|- | |- | ||
− | |06 | + | |06:48 |
|Gives certificates to those who pass an online test | |Gives certificates to those who pass an online test | ||
|- | |- | ||
− | |06 | + | |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 | + | | 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 | + | |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 | + | |07:11 |
|More information on this Mission is available at the following link. | |More information on this Mission is available at the following link. | ||
|- | |- | ||
− | | 07 | + | | 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. | ||
Revision as of 17:51, 9 July 2014
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 Linux12.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 and 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 close double quote semicolon space hash prints Count is 1 |
02:03 | Now Save this file by pressing ctlr 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 a 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 | Lets 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 close double quote 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 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 & Mutli Line Comment. |
06:30 | Watch the video available at the following link |
06:34 | It summarises 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. |