Difference between revisions of "PERL/C2/Comments-in-Perl/English-timed"
From Script | Spoken-Tutorial
Line 21: | Line 21: | ||
|00.18 | |00.18 | ||
|that is, '''Perl''' revision 5 version 14 and subversion 2 | |that is, '''Perl''' revision 5 version 14 and subversion 2 | ||
− | |||
|- | |- | ||
Line 30: | Line 29: | ||
|00.27 | |00.27 | ||
|You can use any text editor of your choice. | |You can use any text editor of your choice. | ||
− | |||
|- | |- | ||
Line 54: | Line 52: | ||
|00.49 | |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 | ||
− | |||
|- | |- | ||
Line 74: | Line 71: | ||
|- | |- | ||
| 01.19 | | 01.19 | ||
− | |Once again, reminding you that the '''ampersand''' is used to free the '''command prompt''' in the '''terminal''' | + | |Once again, reminding you that the '''ampersand''' is used to free the '''command prompt''' in the '''terminal''' and press enter. |
|- | |- | ||
Line 127: | Line 124: | ||
| 02.44 | | 02.44 | ||
|'''Hash exclamation mark slash usr slash bin slash perl''' | |'''Hash exclamation mark slash usr slash bin slash perl''' | ||
− | |||
|- | |- | ||
Line 273: | Line 269: | ||
|06.16 | |06.16 | ||
|Here we learnt, To Add Comments in '''Perl''' | |Here we learnt, To Add Comments in '''Perl''' | ||
− | |||
− | |||
|- | |- | ||
Line 282: | Line 276: | ||
|06.23 | |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. | ||
− | |||
− | |||
|- | |- |
Revision as of 14:44, 2 June 2014
|
|
---|---|
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. |