PERL/C2/Functions-in-Perl/Gujarati
From Script | Spoken-Tutorial
Revision as of 16:53, 3 February 2015 by Jyotisolanki (Talk | contribs)
| Time | Narration |
| 00:01 | પર્લમાં ' Functions પરના ટ્યુટોરીયલમાં તમારું સ્વાગત છે. . |
| 00:06 | આ ટ્યુટોરીયલમાં આપણે આપેલ વિષે શીખીશું- |
| 00:10 | Perl functions (પર્લ ફન્કશન) |
| 00:11 | arguments 'સાથે functions' |
| 00:13 | return values સાથે functions |
| 00:16 | આ ટ્યુટોરીયલ માટે હું વાપરી રહી છું. |
| 00:18 | ઉબુન્ટુ લીનક્સ 12.04 ઓપરેટીંગ સીસ્ટમ |
| 00:22 | પર્લ 5.14.2 અને |
| 00:24 | gedit ટેક્સ્ટ એડિટર |
| 00:27 | તમે તમારી ઈચ્છા અનુસાર કોઈ પણ ટેક્સ્ટ એડિટર વાપરી શકો છો. |
| 00:31 | પર્લમાં તમને વેરીએબલ, કમેન્ટ્સ,લૂપ્સ,કન્ડીશનલ સ્ટેટમેંટ અને ડેટા સ્ટ્રક્ચર વિષે સામાન્ય જાણકારી હોવી જરૂરી છે. |
| 00:41 | સંદર્ભિત ટ્યુટોરીયલો માટે કૃપા કરી સ્પોકન ટ્યુટોરીયલ વેબસાઈટનો સંદર્ભ લો. |
| 00:47 | આપણે પહેલા અમુક સમાન્ય પર્લ ફંક્શન વિષે જોશું. |
| 00:51 | પર્લમાં ફંક્શન ને subroutines, પણ કહેવાય છે જે sub keyword. સાથે ડીકલેર કરવા માં આવે છે. |
| 00:57 | ડીકલેર ફંક્શનની વ્યાખ્યા સર્પાકાર કૌંસ માં લખવા માં આવે છે. |
| 01:03 | આ ફંક્શન કોઈ પણ આર્ગ્યુંમેંટ નથી લેતી. |
| 01:07 | અને આ કઈ પણ પાછુ નથી આપતી. |
| 01:10 | નોંધ: ફંક્શન ની વ્યાખ્યા સ્ક્રીપ્ટમાં કોઈ પણ સ્થાને અથવા કોઈ અન્ય મોડ્યુલમાં લખી શકાય છે. |
| 01:17 | આ મોડ્યુલ પછી આ ફંક્શનનો ઉપયોગ કરીને સ્ક્રીપ્ટમાં સમાવેશ કરવામાં આવે છે. |
| 01:24 | મોડ્યુલ ફાઈલને સ્ક્રીપ્ટમાં સમાવેશ કરવા માટે આપેલ સિન્ટેક્સ નો ઉપયોગ કરવો પડે છે- |
| 01:31 | use ModuleFileName semicolon |
| 01:35 | સેમ્પલ પ્રોગ્રામ નો ઉપયોગ કરીને ચાલો આને સમજીએ. |
| 01:39 | તમારા ટેક્સ્ટ એડિટરને ખોલો અને tene simpleFunction dot pl તરીકે નામ આપો. |
| 01:46 | અહી મારી simpleFunction dot pl ફાઈલ gedit. માં છે. |
| 01:51 | સ્ક્રીન પર બતાડેલ કોડ ટાઈપ કરો. |
| 01:55 | અહી આપણે ફક્ત ફંકશન ને કોલ કરી રહ્યા છે જે આપણે વ્યાખ્યાયિત કર્યું છે. |
| 02:00 | પછી એક્ઝેક્યુશન કંટ્રોલ તે ફંક્શનમાં પાસ થઇ જાય છે. |
| 02:06 | આ ફંક્શનનું ડીકલેરેશન અને વ્યાખ્યા છે. |
| 02:10 | આ ફંક્શન આપેલ ટેક્સ્ટને પ્રિન્ટ કરશે. |
| 02:14 | તમારી ફાઈલ સેવ કરો. |
| 02:17 | પછી પર્લ સ્ક્રીપ્ટ એક્ઝીક્યુટ કરવા માટે ટર્મિનલ પર ટાઈપ કરો |
| 02:24 | perl simpleFunction dot pl |
| 02:28 | અને Enter. દબાઓ. |
| 02:30 | આઉટપુટ ટર્મિનલ પર દ્રશ્યમાન છે. |
| 02:38 | ચાલો હવે ફંકશનને આર્ગ્યુંમેંટ સાથે જોઈએ. |
| 02:44 | ચાલો સેમ્પલ પ્રોગ્રામ વાપરીને આ ફંકશનને સમજીએ. |
| 02:48 | તમારા ટેક્સ્ટ એડિટર ખોલો અને તેને functionWithArgs dot pl નામ આપો. |
| 02:57 | અહી મારી functionWithArgs સ્ક્રીપ્ટ gedit. માં છે. |
| 03:02 | સ્ક્રીન પર બતાવેલ કોડના ભાગને ટાઈપ કરો. |
| 03:07 | અહી આપણે આર્ગ્યુંમેંટ '10 અને 20 સાથે ફંક્શન કોલ કરીશું. |
| 03:13 | પાસ કરેલ આર્ગ્યુંમેંટ $var1 અને $var2.માં મળે છે. |
| 03:20 | @_' એક વિશેષ પર્લ વેરીએબલ છે.આને આપણે પુણ રૂપે આગળના ટ્યુટોરિયલ્સમાં જોશું. |
| 03:29 | આ ફંક્શન બે વેરીએબલસ ને ઉમેરે છે અને જવાબ પ્રિન્ટ કરે છે. |
| 03:37 | ફાઈલ સેવ કરો. |
| 03:42 | @_ એક વિશિષ્ટ પર્લ એરે છે. |
| 03:46 | આ એરેનો ઉપયોગ પાસ કરેલ આર્ગ્યુંમેંટને સેવ કરવા માટે કરી શકાય છે. |
| 03:51 | તેજ રીતે આપણે વેરીએબ્લમાં પાસ કરેલ આર્ગ્યુંમેંટ મેળવીએ છીએ જેમ કે. |
| 03:56 | $var1 space = space shift @_ semicolon |
| 04:04 | $var2 space = space shift @_ semicolon |
| 04:12 | shift @_ એ @_ array પ્રથમ પોજીશન પરથી એલિમેન્ટને હટાવે છે. |
| 04:21 | અને તેને વેરીએબલમાં અસાઇન કરે છે. |
| 04:24 | બીજો માર્ગ છે; $var1 space = space dollar underscrore open square bracket zero બંધ ચોરસ કૌંસ semicolon |
| 04:38 | $var2 space = space dollar underscrore ચોરસ કૌંસ 1 બંધ ચોરસ કૌંસ semicolon |
| 04:49 | ઉપર આપેલ માર્ગ ઇન્ડેક્સ નો ઉપયોગ કરીને @_ array ના એલિમેન્ટને ફેચ કરવા સમાન છે. |
| 04:59 | હવે ટર્મિનલ પર જાઓ સ્ક્રીપ્ટ એક્ઝીક્યુટ કરવા માટે ટાઈપ કરો- |
| 05:06 | perl functionWithArgs dot pl અને Enter દબાઓ. |
| 05:14 | આઉટપુટ સ્ક્રીન પર પ્રદશિત છે. |
| 05:23 | હવે ફંક્શન જોઈએ જે સિંગલ વેલ્યુ પછી આપે. |
| 05:32 | ચાલો તેને સેમ્પલ પ્રોગ્રામ વાપરીને સમજીએ. |
| 05:35 | ચાલો gedit. માં funcWithSingleRtrnVal dot pl સ્ક્રીપ્ટ પર જાઓ. |
| 05:46 | તમારું ટેક્સ્ટ એડિટર ખોલો અને આપેલ કોડનો ભાગ ટાઈપ કરો. |
| 05:52 | અહી આપણે પેરામીટર્સ 10 અને 20 addVariables function કોલ કરી રહ્યા છીએ. |
| 06:01 | ફંક્શનની રીટર્ન વેલ્યુ $addition variable. માં મળે છે. |
| 06:09 | આ ફંક્શન પાસ કરેલ પેરામીટર્સમાં ઉમેરો કરેછે અને જવાબ આપે છે. |
| 06:15 | ફાઈલને સેવ કરો. |
| 06:17 | ચાલો હવે સ્ક્રીપ્ટ એક્ઝીક્યુટ કરીએ. |
| 06:20 | ચાલો ટર્મિનલ પર જાઓ અને ટાઈપ કરો. |
| 06:24 | perl funcWithSingleRtrnVal dot pl અને Enter. દબાઓ. |
| 06:35 | ટર્મિનલ પર આઉટ પુટ દેખાય છે. |
| 06:43 | ચાલો હવે તે ફંક્શન જોશું જે અનેક વેલ્યુ પછી આપે. |
| 06:48 | આને એક સેમ્પલ પ્રોગ્રામ વાપરીને સમજીએ. |
| 06:53 | In gedit માં મેં એક ફાઈલ ખોલી છે જેને funcWithMultipleRtrnVals dot pl નામ આપ્યું છે. |
| 07:04 | Please do like wise in your text editor |
| 07:08 | Now, type the following piece of code as shown. |
| 07:13 | Here, we are calling addVariables function with parameters 10 and 20. |
| 07:21 | The return values of the function are caught in variables $var1, $var2 and $addition |
| 07:31 | This function does the addition and returns the passed parameters and the resultant answer. |
| 07:42 | This illustration demonstrates how we can return an array from a function. |
| 07:53 | Similarly, this demonstrates how hash can be returned from a function. |
| 08:00 | Save your file. |
| 08:03 | Now let us execute the Perl script on the terminal by typing - |
| 08:10 | perl funcWithMultipleRtrnVals dot pl |
| 08:18 | and press Enter. |
| 08:20 | The output is as displayed on the terminal. |
| 08:32 | Perl provides several inbuilt functions. |
| 08:36 | We learnt some of them in earlier tutorials. For eg- Arrays, Hash, sort, scalar, each, keys etc. |
| 08:49 | Calling inbuilt functions, similar to calling any other function, which we define. |
| 08:57 | E.g sort open bracket @arrayName close bracket semicolon |
| 09:04 | Try incorporating some inbuilt functions in the sample programs we used. |
| 09:10 | And observe their outputs. |
| 09:13 | Let us summarize. |
| 09:15 | In this tutorial, we have learnt - |
| 09:17 | Functions in Perl |
| 09:19 | functions with arguments and |
| 09:22 | functions which return values using sample programs. |
| 09:27 | Here is assignment for you - |
| 09:29 | Write a function which takes 3 arguments. |
| 09:33 | Perform some action on these arguments |
| 09:37 | Return the result of the action performed on the arguments and print the same. |
| 09:43 | Watch the video available at the following link |
| 09:47 | It summaries the Spoken Tutorial project |
| 09:51 | If you do not have good bandwidth, you can download and watch it |
| 09:56 | The Spoken Tutorial Project Team Conducts workshops using spoken tutorials |
| 10:02 | Gives certificates to those who pass an online test |
| 10:07 | For more details, please write to contact at spoken hyphen tutorial dot org |
| 10:14 | Spoken Tutorial Project is a part of the Talk to a Teacher project |
| 10:19 | It is supported by the National Mission on Education through ICT, MHRD, Government of India. |
| 10:28 | More information on this Mission is available at spoken hyphen tutorial dot org slash NMEICT hyphen Intro |
| 10:40 | Hope you enjoyed this Perl tutorial. |
| 10:43 | This is Amol signing off. |
| 10:46 | Thanks for joining. |