PERL/C2/Comments-in-Perl/English-timed

From Script | Spoken-Tutorial
Revision as of 11:27, 15 April 2013 by Sneha (Talk | contribs)

Jump to: navigation, search
Visual Cue
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: a. Single Line b. Multi Line


00.50 Single Line'
00.51 This type of comment is used
00.53 when user wants to comment a single line of code or
00.57 to add one liner text to explain the functionality of a piece of code
01.02 This type of comment starts with the symbol # (hash) .
01.07 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 &
01.20 Once again, reminding you that the ampersand is used to free the command prompt in the terminal. And press enter
01.30 Now type the following commands.
01.32 hash Declaring count variable press enter
01.40 dollar count space equal to space 1 semicolon  press enter
01.48 print space double quotes Count is dollar count slash n double quote complete semicolon space hash prints Count is 1
02.06 Now Save this file by pressing ctlr s and execute the Perl script.
02.12 Switch to the Terminal, and type perl hyphen c comments dot pl and press Enter.
02.23 This tells us that there is no syntax error
02.26 Now type perl comments dot pl and press Enter.
02.33    It will show the following output - Count is 1
02.39 Let us switch back to gedit. in gedit, go to the first line and press enter.
02.48 Go back to the first line and type the following command.
02.51 Hash exclamation mark slash usr slash bin slash perl


03.02 This line in Perl is called as a shebang line and is the first line in a Perl program.
03.09 It tells where to find the Perl Interpreter.
03.12 Note: Though this line starts with hash symbol, it will not be considered as a single line comment by Perl.
03.21 Now let us look at multiline comments
03.23 Multi Line This type of comment is used
03.27 when user wants to comment a piece of code or to add description/usage of piece of code
03.35 This type of comment starts with the symbol equal to head and ends with equal to cut
03.43 Lets switch back to gedit and type the following -
03.46 in the comments dot pl file at the end of file type
03.57 equal to head press enter
04.03 print space double quote count variable is used for counting purpose double quote complete press enter
04.24 equal to cut
04.26 Save the file, close it and execute the Perl script.
04.30 On the Terminal, type perl hyphen c comments dot pl and press Enter.
04.40 No syntax error
04.41 so let us execute it perl comments dot pl
04.48   It will show the same output as before. Count is 1
04.55   It does not print the sentence “count variable is be used for counting purpose”
05.02 This is because we commented the portion using equal to head and equal to cut
05.13   You can either use  =head =cut or =begin =end.
05.21 These are not the special keywords used by Perl.
05.24   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.35 Open the Terminal once again.
05.39 And Type - perl gedit commentsExample dot pl & and press Enter.
  05.56   Type the following commands as shown on the screen.
06.02 Here I am declaring two variables firstNum and secondNum and I am assigning some values to them.
06.09 Then I have commented this portion here.
06.15 Now I added these two numbers and assign the value to a third variable named addition.
06.24 Next I want to print the value using print command.
06.31 Save the file and execute the Perl script on the Terminal.
06.37 On terminal type perl hyphen c commentsExample dot pl
06.43 press enter.There is no syntax error
06.47 so execute the script by typing


06.49 perl commentsExample dot pl press enter
  06.56   It will show the following output. Addition is 30
07.05 This brings us to the end of this tutorial.
07.08 Here we learnt, To Add Comments in Perl


07.12 Write a perl script to find square of a number.
07.16 Explain the functionality of the code written using:  Single Line Comment & Mutli Line Comment.


07.23 Watch the video available at the following link
07.27 It summarises the Spoken Tutorial project
07.31 If you do not have good bandwidth, you can  download and watch it
  07.35   The Spoken Tutorial Project Team
07.37 Conducts workshops using spoken tutorials
07.41 Gives certificates to those who pass an online test
07.44 For more details, please write to  contact at spoken hyphen tutorial dot org
07.51 Spoken Tutorial Project is a part of the Talk to a  Teacher project
07.56 It is supported by the National Mission on  Education through ICT, MHRD, Government  of India
08.04 More information on this Mission is available  at the following link.
08.09   Hope you enjoyed this Perl tutorial.  This is Amol Brahmankar signing off.

Thanks for joining.

Contributors and Content Editors

Gaurav, Madhurig, PoojaMoolya, Sandhya.np14, Sneha