PERL/C3/Referencing-and-Dereferencing/Gujarati
From Script | Spoken-Tutorial
Revision as of 15:32, 12 February 2016 by Jyotisolanki (Talk | contribs)
| |
|
| 00:01 | પર્લમાં Referencing and Dereferencing . પરના સ્પોકન ટ્યુટોરીયલમાં તમારું સ્વાગત છે. |
| 00:07 | આ ટ્યુટોરીયલમાં આપણે આપણે શીખીશું:
|
| 00:22 | આ ટ્યુટોરીયલ માટે હું ઉપયોગ કરી રહી છું:
|
| 00:33 | તમે તમારી પસંદગી અનુસાર કોઈ પણ ટેક્સ્ટ એડિટર વાપરી શકો છો. |
| 00:37 | તમને આપેલની કાર્યકારી જાણકારી હોવી જોઈએ:
|
| 00:43 | જો નથી તો સ્પોકન ટ્યુટોરિયલ વેબ સાઈટ પર ઉપલબ્ધ Perl ટ્યુટોરિયલ જુઓ. |
| 00:49 | Reference શું છે? |
| 00:51 | એક reference એક variable, array, hash અથવા એક subroutine નું પોઈન્ત્ર એડ્રેસ હોય છે. |
| 00:58 | આ સીધું ડેટા નથી ધરાવતું. |
| 01:01 | Reference એક સરળ સંક્ષિપ્ત સ્કેલર વેલ્યુ હોય છે. |
| 01:05 | Reference પર્લ કોડના પ્રદશનને સુધારશે જયારે તમે મોટા ડેટા-સ્ટ્રક્ચર ને પાસ અથવા રીટર્ન કરો છો. |
| 01:12 | આ મેમરી સંગ્રહ કરે છે જેમ કે એક વેલ્યુ પાસ પાસ કરવાના બદલે subroutine પર reference પાસ કરે છે. |
| 01:18 | પર્લના જટિલ ડેટા સ્ટ્રક્ચરસ નું સરળતાથી વ્યવસ્થા કરે છે. |
| 01:22 | હવે શીખીએ કે reference ને કેવી રીતે બનાવાય. |
| 01:25 | આપણે આના આગળ એક backslash (\) લગાડીને કોઈ પણ વેરીએબલ , સબરૂટીન અથવા વેલ્યુના માટે reference બનાવી શકીએ છીએ. |
| 01:33 | એક સ્કેલર વેરીએબલ અહી પ્રદશિત ની જેમ backslash (\) અને ડોલર ચિન્હ થી રેફરેન્સ કરાવાય છે. |
| 01:39 | એક array variable backslash (\) અને at the rate(@) સિમ્બલ રેફરેંસ કરાવાય છે. |
| 01:45 | એક hash variable અહી ઉદાહરણમાં પ્રદશિતની જેમ backslash (\) અને percentage(%) સિમ્બલથી રેફરેંસ કરાવાય છે. |
| 01:53 | dereference શું હોય છે ? |
| 01:55 | જયારે એક reference એ dereferenced હોય છે તો વાસ્તવિક વેલ્યુ રીટર્ન થાય છે. |
| 02:00 | Dereference એ reference વેરીએબલને છગડીયા કૌંસમાં સંલગ્ન કરાવાય છે. |
| 02:06 | અને તે કેરેક્ટર જે reference ની જેમ છે છગડીયા કૌંસ ના પહેલા આવે છે. |
| 02:12 | હવે જોઈએ કે વેરીએબલસ ને dereference કેવી રીતે કરે છે. |
| 02:16 | એક scalar વેરીએબલ ડોલર ($) ચિન્હ અને છગડીયા કૌંસ થી ડીરેફરેંસ કરી શકાય છે. |
| 02:21 | એક array વેરીબલ at the rate (@) સિમ્બલ અને છગડીયા કૌંસ થી ડીરેફરેંસ કરી શકાય છે. |
| 02:27 | એક hash variable percentage(%)સિમ્બલ અને છગડીયા કૌંસ થી ડીરેફરેંસ કરી શકાય છે.
|
| 02:33 | હવે Scalar reference અને dereference.. ના માટે એક સરળ પ્રોગ્રામ જોઈએ. |
| 02:38 | ચાલો હું 'gedit' Text editor. માં સેમ્પલ પ્રોગ્રામ ખોલું. |
| 02:43 | ટર્મિનલ ખોલો અને ટાઈપ કરો: gedit scalarRef dot pl ampersand અને એન્ટર દબાવો. |
| 02:50 | સ્ક્રીન પર આપેલની જેમ કોડ ટાઈપ કરો. |
| 02:55 | ચાલો હું કોડ સમજાવું. |
| 02:57 | First line declares a scalar variable '$a' and initialized to 10. |
| 03:03 | As mentioned earlier, a scalar variable is referenced by backslash and dollar sign ($). |
| 03:10 | This line will print memory address of the variable that is created as reference. |
| 03:16 | To print the actual value, the variable is dereferenced by curly brackets preceded by '$'. |
| 03:23 | Here, ref() function will return the reference type such as scalar or array or hash. |
| 03:30 | Now, press Ctrl+S to save the file. |
| 03:34 | ચાલો પ્રોગ્રામ એક્ઝીક્યુટ કરીએ. |
| 03:36 | ટર્મિનલ ખોલો અને ટાઈપ કરો: : perl scalarRef dot pl અને એન્ટર દબાવો. |
| 03:43 | આઉટપુટ આપેલની જેમ દેખાય છે. |
| 03:46 | પ્રથમ લાઈન memory address ને બતાડે છે જ્યાં વેલ્યુ 10 સંગ્રહ કરાવાય છે. |
| 03:51 | બીજી લાઈન વાસ્તવિક વેલ્યુ 10 રીટર્ન કરે છે. |
| 03:55 | Ref() ફંકશન આઉટપુટમાં "SCALAR" રીટર્ન કરે છે. |
| 03:59 | આગળ સમઝીએ કે એક સેમ્પલ પ્રોગ્રામ ઉપયોગ કરીને reference અને dereference એરેને એકવી રીતે બનાવે છે. |
| 04:07 | મારા પાસે પહેલાથી સેમ્પલ પ્રોગ્રામ છે, ચાલો હું તેને gedit ટેક્સ્ટ એડિટર માં ખોલું. |
| 04:13 | ટર્મિનલ પર ટાઈપ કરો : gedit arrayRef dot pl ampersand અને એન્ટર દબાવો. |
| 04:20 | arrayRef dot pl ફાઈલમાં સ્ક્રીન પર પ્રદશિતની જેમ આપેલ કોડ ટાઈપ કરો. |
| 04:26 | ચાલો હું કોડ સમઝાવું. |
| 04:28 | અહી પહેલી લાઈનમાં મેં @color નામક એક એરે ડીકલેર કર્યો છે અને તેને ત્રણ વેલ્યુઓ થી ઇનિશિલાઇઝ કર્યું છે. |
| 04:35 | આ backslash @color થી રેફરેંસ કરવામાં આવે છે જે એરે નામ છે અને $colorRef. ને અસાઇન કરે છે. |
| 04:42 | print સ્ટેટમેંટ reference વેલ્યુ અને dereferenced વેલ્યુને પ્રિન્ટ કરશે. |
| 04:47 | હવે ફાઈલને સેવ કરવા માટે Ctrl+S દબાવો. |
| 04:51 | ચાલો પ્રોગ્રામને એક્ઝીક્યુટ કરીએ. |
| 04:53 | ટર્મિનલ પર જાવ અને ટાઈપ કરો: perl arrayRef dot pl અને એન્ટર દબાવો. |
| 05:00 | આઉટપુટ આપેલની જેમ દેખાય છે. |
| 05:04 | પ્રથમ લાઈન વેરીએબલ ની મેમરી એડ્રેસ નું આઉટપુટ દેખાડે છે જે રેફરેંસ ની જેમ બનાવાઈ છે. |
| 05:10 | બીજી લાઈન વાસ્તવિક વેલ્યુ દેખાડે છે જે ડીરેફરેંસ કરવાઈ છે. |
| 05:16 | આગળ આપણે જોશું કે એક array ના લીધે ડાયરેક્ટ રેફરેંસને કેવી રીતે ડીકલેર કરાય છે. |
| 05:21 | ચાલો અપણા પ્રોગ્રામ પર પાછા જઈએ. |
| 05:24 | મેં એક એરે ને direct reference ને બતાડવા માટે વર્તમાન પ્રોગ્રામને બદલ્યું છે. |
| 05:29 | તમે દેખાડેલ ની જેમ ચોરસ કૌંસ '[ ]' નો ઉપયોગ કરીને એક એરેના માટે direct reference બનાવી શકો છો. |
| 05:35 | dereference કરવા માટે arrow operator (->) નો ઉપયોગ કરો. |
| 05:39 | print સ્ટેટમેંટ આઉટપુટ ની જેમ "Green" પ્રિન્ટ કરશે. |
| 05:43 | અહી પ્રિન્ટ સ્ટેટમેંટ ઇન્ડેક્સ ઓફ [1] ની વેલ્યુ લે છે જે આપના પ્રોગ્રામમાં Green છે. |
| 05:50 | ફાઈલ સેવ કરવા માટે Ctrl+S દબાવો. |
| 05:54 | ટર્મિનલ પર ટાઈપ કરો perl arrayRef dot pl અને એન્ટર દબાવો. |
| 06:03 | I’ll show an example on how to use the direct hash reference in the same code file.
So, let’s switch to gedit. |
| 06:11 | You can create a direct reference to hash by using curly brackets {} as shown here. |
| 06:18 | Use arrow operator (->) to dereference it. “Name” is the hash key. |
| 06:24 | On executing this block of code, both the print statements will print "Sunil" as output. |
| 06:31 | Next we will see how to add, remove, access elements to array reference with a sample program. |
| 06:39 | I already have a sample program. Let me open it in gedit text-editor. |
| 06:45 | Open the terminal and type: gedit arrayRefadd dot pl ampersand and press Enter. |
| 06:54 | 'arrayRefadd.pl' file is now open in gedit. Type the code as shown here, in your file. |
| 07:02 | The first line initializes an array. |
| 07:06 | We have referenced an array with backslash @numarray and assigned to $ref. |
| 07:13 | Now, we will see how to access a particular element from the array reference. |
| 07:19 | We need to use the array index in square brackets “[ ]” to access the particular value and an arrow operator (“->”) to dereference it. |
| 07:28 | The print statement will print the value of index [0]. |
| 07:32 | push() function adds elements at the last position of an array reference.
In our case, 5, 6, 7 are added to the end of the existing array 1, 2, 3, 4. |
| 07:47 | This print statement shows the output, after adding to the array reference. |
| 07:53 | pop() function removes an element from the last position of an array reference. |
| 07:58 | In our example, 7 will be removed from the existing array reference. |
| 08:03 | print statement shows the output after deleting from the array reference. |
| 08:08 | Now, press Ctrl+S to save the file. |
| 08:11 | Let us execute the program. |
| 08:14 | Switch back to the terminal and type: perl arrayRefadd dot pl and press Enter. |
| 08:22 | The output is displayed as shown here. |
| 08:26 | Now, let us see another sample program to add, remove, and access elements of hash reference. |
| 08:34 | On the terminal, type: gedit hashRefadd dot pl ampersand and press Enter. |
| 08:42 | This will open the file 'hashRefadd.pl' in gedit. |
| 08:47 | Let me explain the sample program. |
| 08:50 | I have declared a direct hash reference that can be stored in a scalar variable $weektemp. |
| 08:57 | I have used curly brackets to represent the hash reference and the arrow operator to dereference. |
| 09:04 | This code stores the temperature values from Monday to Friday. |
| 09:09 | I am using the “keys” built-in function to loop through the keys of the hash. |
| 09:15 | print statement will print each element of the hash. |
| 09:19 | We can access the particular value of an element as shown here. |
| 09:25 | print statement will print the temperature on Monday. |
| 09:29 | Now, save the file. |
| 09:32 | Switch to terminal and type: perl hashRefadd dot pl and press Enter to see the output. |
| 09:41 | The hash keys and hash values are stored in a random order. |
| 09:46 | The displayed output is not related to the order in which they were added. |
| 09:52 | With this, we come to the end of this tutorial. Let us summarize. |
| 09:57 | In this tutorial, we learnt about:
|
| 10:14 | Here is an assignment for you. Add new keys “Saturday” and “Sunday” in hash weektemp, in our hashRefadd dot pl file. |
| 10:24 | Delete key “Saturday” at the end. |
| 10:27 | Print hash weektemp. |
| 10:30 | Save and execute the program. Now check the result. |
| 10:35 | The video at the following link summarizes the Spoken Tutorial project.
Please download and watch it. |
| 10:42 | We conduct workshops and give certificates for those who pass our online tests.
For more details, please write to us. |
| 10:51 | Spoken Tutorial project is funded by NMEICT, MHRD, Government of India.
More information on this mission is available at this link. |
| 11:02 | This is Nirmala Venkat from IIT Bombay, signing off. Thanks for watching. |