Difference between revisions of "PERL/C2/Data-Structures/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(5 intermediate revisions by 2 users not shown)
Line 41: Line 41:
 
|-
 
|-
 
|00:44
 
|00:44
|'''Scalar'''
+
|'''Scalar''', '''Array'''
+
|-
+
| 00:45
+
| '''Array'''
+
 
   
 
   
 
|-
 
|-
 
|00:46
 
|00:46
|'''Hash''', also called as '''Associative Array'''.
+
| '''Hash''', also called as '''Associative Array'''.
  
 
|-
 
|-
Line 65: Line 61:
 
|-
 
|-
 
|01:06
 
|01:06
|Note: Reference in '''Perl''' will be covered in subsequent tutorial.  
+
|Note: '''Reference''' in '''Perl''' will be covered in subsequent tutorial.  
  
 
|-
 
|-
 
| 01:11
 
| 01:11
| '''Scalar''' type of  data structure is as simple as declaring the variable.  
+
|'''Scalar''' type of  data structure is as simple as declaring the variable.  
  
 
|-
 
|-
Line 85: Line 81:
 
|-
 
|-
 
|01:30
 
|01:30
|* Assign a value to it.  
+
|Assign a value to it.  
 
   
 
   
 
|-
 
|-
 
|01:32
 
|01:32
|* Assign one scalar to another.  
+
|Assign one scalar to another.  
 
   
 
   
 
|-
 
|-
 
|01:35
 
|01:35
|* Arithmetic operations on '''number''' type of scalars like add, subtract etc.
+
|Arithmetic operations on '''number''' type of scalars like add, subtract etc.
 
   
 
   
 
|-
 
|-
 
| 01:41
 
| 01:41
|* String operations on string scalar like '''concatenation, substr''' etc.  
+
| String operations on string scalar like '''concatenation, substr''' etc.  
  
 
|-
 
|-
Line 105: Line 101:
 
|-
 
|-
 
|01:52
 
|01:52
| Switch to terminal and type: '''gedit scalars dot pl''' space '''&''' and press '''Enter.'''  
+
| Switch to terminal and type: '''gedit scalars dot pl''' space & (ampersand) and press '''Enter.'''  
  
 
|-
 
|-
 
| 02:01
 
| 02:01
| This will open the 'scalars dot pl file' in '''gedit'''.  
+
| This will open the 'scalars dot pl' file in '''gedit'''.  
 
   
 
   
 
|-
 
|-
Line 133: Line 129:
 
|-
 
|-
 
|02:30
 
|02:30
| Here 'index 0' specifies start of a '''string''', i.e. from where we want to start extraction of the '''string.'''
+
| Here, '''index 0''' (zero) specifies start of a '''string''', i.e. from where we want to start extraction of the '''string.'''
  
 
|-
 
|-
 
|02:39
 
|02:39
|And 11 specifies the '''offset''' upto where we want the '''string''' to be in the output.  
+
|And, 11 specifies the '''offset''' upto where we want the '''string''' to be in the output.  
 
   
 
   
 
|-
 
|-
Line 168: Line 164:
 
   
 
   
 
|-
 
|-
| 03:16
+
|03:16
 
| It has an '''index''' which is used for performing various operations on the '''array'''.  
 
| It has an '''index''' which is used for performing various operations on the '''array'''.  
 
   
 
   
 
|-
 
|-
|   03:22
+
| 03:22
 
| '''Index''' starts with zero.  
 
| '''Index''' starts with zero.  
 
   
 
   
Line 281: Line 277:
 
|-
 
|-
 
|05:41
 
|05:41
|Press '''Enter '''
+
|Press '''Enter '''. '''single quote key Name single quote space equal to greater than sign space Value comma'''  
 
+
|-
+
|05:42
+
|'''single quote key Name single quote space equal to greater than sign space Value comma'''  
+
 
   
 
   
 
|-
 
|-
Line 361: Line 353:
 
|-
 
|-
 
|  07:05
 
|  07:05
| Let us summarize.  
+
| Let us summarize. In this tutorial, we have learnt -  
+
|-
+
|  07:06
+
In this tutorial, we have learnt -  
+
 
   
 
   
 
|-
 
|-
 
|07:09
 
|07:09
|* '''scalar'''
+
|'''scalar''', '''Array''' and  
   
+
|-
+
|07:10
+
|* '''Array''' and  
+
 
   
 
   
 
|-
 
|-
 
|07:11
 
|07:11
|* '''Hash Data Structure''' in '''Perl''',  
+
| '''Hash Data Structure''' in '''Perl''',  
 
 
 
 
 
|-
 
|-
Line 385: Line 369:
 
|-
 
|-
 
|07:15
 
|07:15
| There is assignment for you -  
+
| There is an assignment for you -  
  
 
|-
 
|-
 
|07:17
 
|07:17
|* Declare '''scalar variable'''  
+
| Declare '''scalar variable'''  
  
 
|-
 
|-
 
|07:19
 
|07:19
|* Assign value of '''type float''' to it and then print it.  
+
| Assign value of '''type float''' to it and then print it.  
  
 
|-
 
|-
 
|07:23
 
|07:23
|* Declare and print an array of colors 'Red', 'Yellow' and 'Green'.  
+
| Declare and print an array of colors 'Red', 'Yellow' and 'Green'.  
 
   
 
   
 
|-
 
|-
 
|07:28
 
|07:28
|* Declare and print a '''hash''' of '''Employee Name''' and their '''department'''.  
+
| Declare and print a '''hash''' of '''Employee Name''' and their '''department'''.  
  
 
|-
 
|-
Line 425: Line 409:
 
|-
 
|-
 
| 07:53
 
| 07:53
| The Spoken Tutorial project team:  Conducts workshops using spoken tutorials.
+
|The Spoken Tutorial project team:  Conducts workshops using spoken tutorials.
 
   
 
   
 
|-
 
|-
Line 433: Line 417:
 
|-
 
|-
 
|08:03
 
|08:03
|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.
 
   
 
   
 
|-
 
|-
Line 445: Line 429:
 
|-
 
|-
 
|08:22
 
|08:22
|More information on this mission is available at spoken hyphen tutorial dot org slash NMEICT hyphen Intro.
+
|More information on this mission is available at: spoken hyphen tutorial dot org slash NMEICT hyphen Intro.
 
   
 
   
 
|-
 
|-
 
| 08:33
 
| 08:33
| Hope you enjoyed this '''Perl''' tutorial.  
+
|Hope you enjoyed this '''Perl''' tutorial.  
 
   
 
   
 
|-
 
|-

Latest revision as of 12:33, 24 March 2017

Time Narration
00:00 Welcome to the spoken tutorial on Data Structures in Perl.
00:05 In this tutorial, we will learn about Data Structures available in Perl.
00:11 Here, I am using Ubuntu Linux 12.04 operating system and Perl 5.14.2.
00:18 I will also be using the gedit Text Editor.
00:22 You can use any text editor of your choice.
00:25 You should have basic knowledge of variables in Perl.
00:29 Knowledge of comments, loops and conditional statements will be an added advantage.
00:36 Please go through the relevant spoken tutorials on the Spoken Tutorial website.
00:41 Perl has 3 types of data structures:
00:44 Scalar, Array
00:46 Hash, also called as Associative Array.
00:50 Scalar: This type of data structure holds a value of any data type.
00:56 The data type can be string, number, double etc.
01:01 It can also hold the reference to an array or reference to a hash.
01:06 Note: Reference in Perl will be covered in subsequent tutorial.
01:11 Scalar type of data structure is as simple as declaring the variable.
01:16 $count = 12 semicolon.
01:20 $string = in single quote 'I am scalar of type string' semicolon.
01:26 We can perform the following operations on scalar.
01:30 Assign a value to it.
01:32 Assign one scalar to another.
01:35 Arithmetic operations on number type of scalars like add, subtract etc.
01:41 String operations on string scalar like concatenation, substr etc.
01:48 Now, let us look at an example of scalar data structure.
01:52 Switch to terminal and type: gedit scalars dot pl space & (ampersand) and press Enter.
02:01 This will open the 'scalars dot pl' file in gedit.
02:05 Type the following code as displayed on the screen.
02:09 This is the declaration and assignment to the scalar.
02:13 These are few arithmetic operations that can be performed on number type of scalar.
02:19 These are the string operations that can be performed on string type of scalar.
02:25 substr is the PERL function which provides part of the string as output.
02:30 Here, index 0 (zero) specifies start of a string, i.e. from where we want to start extraction of the string.
02:39 And, 11 specifies the offset upto where we want the string to be in the output.
02:46 Press Ctrl + s to save the file.
02:50 Then switch to the terminal and execute the Perl script as:
02:55 perl scalars dot pl and press Enter.
03:00 The output shown on terminal is as highlighted.
03:05 Now, let us look at an array data structure in PERL.
03:09 Array: It is a list of elements.
03:12 Elements can be string, number etc.
03:16 It has an index which is used for performing various operations on the array.
03:22 Index starts with zero.
03:25 Unlike other programming languages, there is no need to declare an array or its length before using it in Perl.
03:33 Perl array stretches or shrinks as per the elements added or removed from it.
03:39 The syntax to write an array is:
03:41 at the rate (@) variableName space equal to space open bracket list of elements separated with comma close bracket semicolon.
03:54 Now, let us look at an example of array data structure.
03:57 Switch to terminal and type: gedit perlArray dot pl space & and press Enter.
04:08 This will open the perlArray dot pl file in gedit.
04:12 Type the following code as displayed on the screen.
04:18 This is the number array which has elements of number type.
04:23 This is the string array which has elements of string type.
04:29 This array has elements of both number and string type.
04:34 This example shows the various types of arrays in Perl.
04:39 This is how we can print the array in Perl.
04:43 Press Ctrl + S to save the file.
04:47 Then switch to terminal and execute the Perl script as:
04:52 perl perlArray dot pl and press Enter.
04:59 The following output is displayed on the terminal.
05:04 Now, let us look at Hash data structure in Perl.
05:08 Hash is alternatively called as Associative array.
05:12 It is a Key - Value pair data structure.
05:15 Key in hash is unique.
05:18 If the same key is added again, then the value of that key will be overridden by the latest value assigned to the key.
05:28 Value can be duplicate.
05:30 It also holds value of any data type.
05:34 The syntax of hash is:
05:36 percentage variable name space equal to space open bracket
05:41 Press Enter . single quote key Name single quote space equal to greater than sign space Value comma
05:50 Press Enter
05:52 single quote key Name single quote space equal to greater than sign space Value
05:58 Press Enter
06:00 close bracket semicolon.
06:03 Now let us look at an example of hash data structure.
06:07 Switch to terminal and type:
06:10 gedit perlHash dot pl space & and press Enter.
06:18 This will open the 'perlHash dot pl' file in gedit.
06:22 Type the following code as displayed on the screen.
06:27 This hash indicates the marks obtained in a subject.
06:31 This example shows the use of hash.
06:35 Now, let us see how to print the hash.
06:38 For now, just note the way I have printed the hash.
06:42 Detailed explanation will be given in subsequent tutorial.
06:47 Press Ctrl + S to save the file.
06:50 Then switch to terminal and execute the Perl script as:
06:55 perl perlHash dot pl and press Enter.
07:01 The following output is displayed on the terminal.
07:05 Let us summarize. In this tutorial, we have learnt -
07:09 scalar, Array and
07:11 Hash Data Structure in Perl,
07:13 using sample programs.
07:15 There is an assignment for you -
07:17 Declare scalar variable
07:19 Assign value of type float to it and then print it.
07:23 Declare and print an array of colors 'Red', 'Yellow' and 'Green'.
07:28 Declare and print a hash of Employee Name and their department.
07:33 Hint: 'Employee' =>(equal to greater than sign) 'John' comma
07:38 'Department' =>(equal to greater than sign) 'Engineering'.
07:42 Watch the video available at the following link.
07:46 It summarizes the Spoken Tutorial project.
07:49 If you do not have good bandwidth, you can download and watch it.
07:53 The Spoken Tutorial project team: Conducts workshops using spoken tutorials.
07:59 Gives certificates to those who pass an online test.
08:03 For more details, please write to: contact at spoken hyphen tutorial dot org.
08:10 "Spoken Tutorial" project is a part of the "Talk to a Teacher" project.
08:15 It is supported by the National Mission on Education through ICT, MHRD, Government of India.
08:22 More information on this mission is available at: spoken hyphen tutorial dot org slash NMEICT hyphen Intro.
08:33 Hope you enjoyed this Perl tutorial.
08:35 This is Amol, signing off.
08:38 Thanks for joining.

Contributors and Content Editors

Gaurav, PoojaMoolya, Sandhya.np14