PERL/C2/Conditional-statements/Gujarati
From Script | Spoken-Tutorial
Revision as of 11:32, 7 August 2014 by Jyotisolanki (Talk | contribs)
Time | Narration |
00:01 | પર્લમા if and if-else conditional statements પરનાં સ્પોકન ટ્યુટોરીયલમાં સ્વાગત છે. |
00:07 | આ ટ્યુટોરીયલમાં, આપણે આપેલ વિશે શીખીશું; |
00:09 | if સ્ટેટમેન્ટ અને |
00:11 | પર્લમા if-else સ્ટેટમેન્ટ |
00:12 | હું વાપરી રહ્યી છું ઉબુન્ટુ લીનક્સ 12.04 ઓપરેટીંગ સીસ્ટમ અને પર્લ Perl 5.14.2 |
00:20 | તેમજ હું gedit ટેક્સ્ટ એડીટર પણ વાપરીશ. |
00:24 | તમે તમારા પસંદનું કોઈપણ ટેક્સ્ટ એડીટર વાપરી શકો છો. . |
00:28 | તમને પર્લમાં વેરીએબલો અને કમેંટોની સામાન્ય જાણકારી હોવી અનિવાર્ય છે. |
00:33 | પર્લમાં for અને foreach લૂપ્સ નું જ્ઞાન હોવાથી વધારાના લાભ થશે. |
00:40 | સ્પોકન ટ્યુટોરીયલ વેબસાઈટ પર સંદર્ભિત સ્પોકન ટ્યુટોરીયલોનો સંદર્ભ લો. |
00:45 | પર્લ આપેલ કંડીશનલ સ્ટેટમેન્ટ પૂરી પાડે છે - |
00:49 | if (ઇફ) |
00:50 | if-else (ઇફ) |
00:51 | if-elsif-else અને ( ઇફ -એલ્સઇફ -એલ્સ) |
00:53 | switch (સ્વીચ) |
00:54 | આ ટ્યુટોરીયલમાં આપણે if અને If-else સ્ટેટમેન્ટ ને આવરી લેશું. |
00:59 | પર્લમાં ઇફ સ્ટેટમેન્ટ નો ઉપયોગ |
01:01 | જયારે નિર્દિષ્ટ કન્ડીશન સંતુષ્ટજનક હોય ત્યારેજ કોડ ના ભાગ ને એક્ઝીક્યુટ કરે છે. |
01:07 | if કન્ડીશન સ્ટેટમેન્ટનું સિન્ટેક્સ આપ્યા પ્રમાણે છે: |
01:11 | if space open bracket condition close bracket space Open curly bracket |
01:19 | Enter |
01:20 | Piece of code semicolon, to be executed when the condition is true |
01:25 | Enter, Close curly bracket |
01:29 | The code inside the if statement will be executed only when the condition is true. |
01:36 | Now let us look at an example of if statement. |
01:40 | Open the Terminal and type |
01:43 | gedit conditionalBlocks dot pl space &(ampersand ) |
01:49 | and press Enter |
01:52 | This will open the conditionalBlocks.pl file in gedit. |
01:57 | Type the following piece of code as displayed on the screen. |
02:02 | Here we have specified a condition for if which checks the value of variable count. |
02:09 | Note the equal to equal to sign here. This is the comparison operator. |
02:15 | The condition $count equal to equal to 5 is checked against the value of variable count. |
02:23 | When it is equal to 5, the code within the if block will get executed. |
02:28 | Now, press ctrl+s to save the file. |
02:32 | Then switch to the terminal. |
02:36 | Make sure that you are in the directory in which you have saved your file. |
02:41 | Type the following to check for any compilation or syntax error - |
02:46 | perl hyphen c conditionalBlocks dot pl |
02:53 | and press Enter. |
02:55 | The following line will be displayed on the terminal window |
02:59 | conditionalBlocks.pl syntax OK |
03:04 | As there is no compilation or syntax error, we will execute the Perl script by typing - |
03:10 | perl conditionalBlocks dot pl |
03:14 | and press Enter |
03:16 | The following output will be shown on terminal. |
03:19 | I am inside if statement |
03:23 | Switch back to gedit |
03:26 | Alternately, we can write the above if statement as- |
03:31 | print space double quotes I am inside if statement slash n close double quotes space if open bracket dollar count space equal to equal to space 5 close bracket semicolon. |
03:57 | Now, let us look at if-else statement. |
04:01 | This statement is used when user wants to execute |
04:06 | one piece of code when the condition is true and |
04:09 | another piece of code when the condition is false |
04:13 | The syntax for if-else condition is as follows - |
04:17 | if space open bracket condition close bracket space open curly bracket Press Enter. |
04:27 | piece of code semicolon |
04:29 | to be executed when if condition is true, |
04:32 | Press Enter |
04:34 | close curly bracket space else space open curly bracket Enter |
04:41 | another piece of code semicolon |
04:43 | to be executed when if condition is false |
04:47 | Press Enter close curly bracket |
04:51 | Now again, go to the conditionalBlocks.pl file which we have already created in gedit. |
04:58 | Assign 4 to count variable then at the end of the if block type space |
05:07 | else |
05:09 | space open curly bracket press Enter |
05:14 | print space double quotes I am inside else statement slash n close double quotes semicolon |
05:30 | Press Enter and close curly bracket. |
05:34 | Here, 4 is assigned to variable $count. |
05:38 | As the value of count variable does not match 5, |
05:43 | the code within the if block will not get execute |
05:47 | instead the code within the else block will get execute. |
05:52 | Now press Ctrl+S to save the file. |
05:56 | Now switch to terminal. |
05:59 | and type perl hyphen c conditionalBlocks dot pl to check for any compilation or syntax error |
06:11 | now, press Enter |
06:13 | The following line will be displayed on the terminal |
06:17 | conditionalBlocks.pl syntax OK |
06:20 | As there is no compilation or syntax error, we will now execute the Perl script. |
06:27 | Type perl conditionalBlocks dot pl |
06:33 | and press Enter |
06:35 | The following output will be shown on terminal. |
06:39 | I am inside else statement |
06:44 | Let us summarize. |
06:46 | In this tutorial, we have learnt - |
06:49 | if and |
06:50 | if-else conditional statements in Perl |
06:53 | using sample programs. |
06:55 | Here is assignment for you - |
06:57 | Print “It is an open source language” |
07:01 | when the variable declared has value 'Perl' |
07:04 | otherwise print “It's a proprietary language” |
07:08 | Watch the video available at the following link |
07:11 | It summaries the Spoken Tutorial project |
07:15 | If you do not have good bandwidth, you can download and watch it |
07:20 | The Spoken Tutorial Project Team |
07:22 | Conducts workshops using spoken tutorials |
07:26 | Gives certificates to those who pass an online test |
07:31 | For more details, please write to contact at spoken hyphen tutorial dot org |
07:37 | Spoken Tutorial Project is a part of the Talk to a Teacher project |
07:42 | It is supported by the National Mission on Education through ICT, MHRD, Government of India. |
07:50 | More information on this Mission is available at spoken hyphen tutorial dot org slash NMEICT hyphen Intro |
08:00 | Hope you enjoyed this Perl tutorial. |
08:04 | This is Amol Brahmankar signing off. |
08:06 | Thanks for joining. |