Difference between revisions of "PERL/C3/File-Handling/Gujarati"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 3: Line 3:
 
|  '''Time'''
 
|  '''Time'''
 
|  '''Narration'''
 
|  '''Narration'''
 
  
 
|-
 
|-
Line 76: Line 75:
  
 
|-
 
|-
| 01:
+
| 01:38
 
|  પ્રથમ આપણે એક ટેક્સ્ટ ફાઈલ બનાવીશું અને તેમાં અમુક ડેટા સંગ્રહીશું.ટર્મિનલ પર જાવ અને ટાઈપ કરો  '''gedit ''  first.txt'''  અને એન્ટર દબાવો.
 
|  પ્રથમ આપણે એક ટેક્સ્ટ ફાઈલ બનાવીશું અને તેમાં અમુક ડેટા સંગ્રહીશું.ટર્મિનલ પર જાવ અને ટાઈપ કરો  '''gedit ''  first.txt'''  અને એન્ટર દબાવો.
  
Line 280: Line 279:
 
|-
 
|-
 
| 06:14
 
| 06:14
| The previous contents of the 'second.txt' file has been overwritten.
+
|   '''second.txt'''  ફાઈલના પાછલા કન્ટેન્ટ ઓવરરાઈટ થયી ગયા છે.
  
 
|-
 
|-
 
| 06:19
 
| 06:19
This is because, we had opened the file in the "write" mode again.
+
આવું એટલા માટે કારણકે આપણે "write" મોડમાં ફરીથી ફાઈલ ખોલી હતી.
  
 
|-
 
|-
 
| 06:24
 
| 06:24
| Let us close the 'second.txt' file.
+
| ચાલો 'second.txt' ફાઈલ ને બંદ કરો.
  
 
|-
 
|-
 
|  06:27
 
|  06:27
| Next, we will see how to append data to an existing file.
+
|   આગળ આપણે જોશું કે વર્તમાન ફાઈલમાં ડેટા કેવી રીતે ઉમેરીશું.
  
 
|-
 
|-
 
|  06:32
 
|  06:32
The '''open '''statement with two '''greater than''' (>>) symbols denotes the "APPEND" mode.
+
બે  '''greater than''' (>>) સિમ્બોલના સાથે ઓપન સ્ટેટમેન્ટ  "APPEND" મોડને દેખાડે છે.
  
 
|-
 
|-
 
|  06:38
 
|  06:38
| Now I will open the '''writefile dot pl''' again in '''gedit'''.
+
|   હવે હું ફરીથી '''gedit''' માં '''writefile dot pl''' ફાઈલ ખોલીશ.
  
 
|-
 
|-
 
| 06:44
 
| 06:44
| In the '''open''' statement, type two '''greater (>>) than''' symbols. This will denote that the file is in '''append mode.'''
+
| ઓપન સ્ટેટમેન્ટ  માં ટાઈપ કરો '''greater (>>) than''' સિમ્બોલ આ બતાડશે કે ફાઈલ ''append mode.''' માં છે.
  
 
|-
 
|-
 
|  06:52
 
|  06:52
|''' Comment'''  the previous '''print''' statement, as it is already executed.
+
| પાછલા પ્રિન્ટ સ્ટેટમેન્ટને ''' Comment'''  કરો જેવું કે આ પહલા એક્ઝીક્યુટ થયું છે.
  
 
|-
 
|-
 
|  06:57
 
|  06:57
Add the line: '''print FILE1''' within double quotes "Two greater than symbols (>>) open the file in append mode", to append to the existing data.
+
વર્તમાન ડેટા ને ઉમેરવા માટે એક  લાઈન ઉમેરો : '''print FILE1''' ડબલ કોટમાં  "Two greater than symbols (>>) open the file in append mode".
  
 
|-
 
|-
 
|  07:07
 
|  07:07
Now, press''' Ctrl+S''' to '''save''' the file.
+
હવે ફાઈલ ને સેવ કરવા માટે ''' Ctrl+S''' દબાવો.
  
 
|-
 
|-
 
|  07:11
 
|  07:11
| Let us '''execute''' the program.
+
|   ચાલો પ્રોગ્રામ ને એક્ઝીક્યુટ કરો.
  
 
|-
 
|-
 
|  07:14
 
|  07:14
Switch back to the '''terminal''' and type: '''perl writefile dot pl''' and press''' Enter'''.
+
|  ટર્મિનલ પર જાવ અને ટાઈપ કરો : '''perl writefile dot pl''' અને એન્ટર દબાવો.
 
+
|-
+
|  07:20
+
|  Now, let us check whether the text has been appended to the 'second.txt' file.
+
 
+
|-
+
| 07:26
+
|  Type: ''' gedit second.txt''' and press '''Enter'''.
+
 
+
|-
+
|  07:31
+
|  We can see the text has been appended in our 'second.txt' file.
+
 
+
|-
+
| 07:36
+
| Let us close the 'second.txt' file.
+
 
+
|-
+
|  07:39
+
|  Similarly, there are other modes also.
+
 
+
|-
+
| 07:42
+
| Try out these options on your own and understand what happens.
+
 
+
|-
+
|  07:49
+
|  This brings us to the end of this tutorial. Let us summarize.
+
 
+
|-
+
|  07:53
+
|  In this tutorial, we learnt to:
+
* Open a file in "read" mode
+
* Write to a file
+
* Open a file in "append" mode and
+
* Close the '''file handle'''.
+
 
+
|-
+
|  08:03
+
|  Here is an assignment for you. Change the '''file attribute''' to "+>" in the 'writefile.pl' program.
+
 
+
|-
+
| 08:11
+
| '''Save''' and '''execute''' the program.
+
 
+
|-
+
| 08:14
+
|  Open the 'second.txt' file to see the output.
+
 
+
|-
+
| 08:17
+
| Analyze the usage of file attribute "+>".
+
 
+
|-
+
|  08:22
+
|  The video at the following link summarizes the '''Spoken Tutorial''' project. Please download and watch it.
+
 
+
|-
+
|  08:29
+
|  The''' Spoken Tutorial Project''' team:
+
* conducts workshops using spoken tutorials and
+
* gives certificates on passing online tests.
+
 
+
|-
+
| 08:37
+
|  For more details, please write to us.
+
 
+
|-
+
|  08:41
+
|  Spoken Tutorial project is funded by NMEICT, MHRD, Government of India.
+
 
+
|-
+
| 08:48
+
|  More information on this mission is available at this link.
+
|-
+
|  08:53
+
|  This is Nirmala Venkat from '''IIT Bombay''', signing off. Thanks for watching.
+
 
+
|} 
+
 
+
|-
+
|  00:06
+
|  આ ટ્યુટોરીયલમાં આપણે આપણે શીખીશું:
+
* '''read mode''' માં ફાઈલ ખોલવી
+
*  ફાઈલ કેવી રીતે લખવી
+
*  '''append mode''' માં ફાઈલ ખોલવી
+
*  '''file handle''' ને કેવી રીતે બંદ કરવી.
+
 
+
|-
+
| 00:17
+
|  આ ટ્યુટોરીયલ માટે હું ઉપયોગ કરી રહી છું:
+
* '''Ubuntu Linux 12.04''' operating system
+
* '''Perl 5.14.2''' અને
+
* ''' gedit''' ટેક્સ્ટ એડિટર .
+
 
+
|-
+
| 00:28
+
| તમે તમારી પસંદગી અનુસાર કોઈ પણ ટેક્સ્ટ એડિટર વાપરી શકો છો.
+
 
+
|-
+
| 00:32
+
| આ ટ્યુટોરીયલના અનુસરણ માટે તમને ''' Perl '' પ્રોગ્રામિંગ વિષે સામાન્ય જાણકારી હોવી જોઈએ.
+
 
+
|-
+
| 00:37
+
|જો નથી તો સ્પોકન ટ્યુટોરિયલ વેબ સાઈટ પર ઉપલબ્ધ ''' Perl ''' ટ્યુટોરિયલ જુઓ.
+
 
+
|-
+
|  00:43
+
| મૂળભૂત ઓપરેશન જે આપણે પર્લમાં  ફાઈલ્સ સાથે કરી શકીએ છીએ તે છે:
+
* ફાઈલ ખોલવી
+
*  ફાઈલમાં થી વાંચવું.
+
* ફાઈલ પર લખવું.
+
* ફાઈલ બંદ કરવી.
+
 
+
|-
+
|00:54
+
|''' file handles ''' are: મૂળભૂત ''' file handles '''  છે.
+
* '''STDIN'''
+
* '''STDOUT'''
+
* '''STDERR'''
+
 
+
|-
+
|  01:02
+
|  આ '''open ''' ફંકશન માટે સિન્ટેક્સ છે.
+
 
+
|-
+
| 01:05
+
|  સિન્ટેક્સમાં '''FILEHANDLE'''  એ ફાઈલ હેન્ડલ છે જે '''open ''' ફંકશન થી રીટર્ન થાય છે.
+
 
+
|-
+
| 01:11
+
|  '''MODE''' ફાઈલ ખોલવું જેવા: રીડ, રાઈટ વગેરે મોડ ને બતાડે છે.
+
 
+
|-
+
| 01:18
+
|  '''EXPR'''  એ ભૌતિક ફાઈલનનું નામ છે જે  વાંચવા અને લખવામાં ઉપયોગ થાય છે.
+
 
+
|-
+
| 01:27
+
|  અહી પ્રદશિતની જેમ  '''open ''' ફંકશન ને લખવા માટે અન્ય માર્ગ છે.
+
 
+
|-
+
|  01:32
+
| ચાલો સમઝીએ વર્તમાન ફાઈલને કેવી રીતે ખોલવી અને તેમાંથી ડેટા કેવી રીતે વાંચવા.
+
 
+
|-
+
| 01:
+
|  પ્રથમ આપણે એક ટેક્સ્ટ ફાઈલ બનાવીશું અને તેમાં અમુક ડેટા સંગ્રહીશું.ટર્મિનલ પર જાવ અને ટાઈપ કરો '''gedit ''  first.txt'''  અને એન્ટર દબાવો.
+
 
+
|-
+
|01:51
+
|  '''first dot txt''' ફાઈલમાં આપેલ ટેક્સ્ટ ટીપ કરો:
+
 
+
|-
+
| 01:55
+
|  ફાઈલ ને સેવ કરીને ''' gedit'''  બંદ કરો.
+
 
+
|-
+
|  01:59
+
| હવે આપણે એક '''Perl '''પ્રોગ્રામ જોશું જે '''first.txt''' ફાઈલ ખોલે છે અને વિષય વસ્તુ વાંચે છે.
+
 
+
|-
+
|  02:07
+
|  હવે હું '''openfile.pl''' સેમ્પલ પ્રોગ્રામ ખોલીશ. જે મેં પહેલાથી જ સેવ કરેલ છે.
+
 
+
|-
+
| 02:13
+
|  ટાઈપ કરો :  '''gedit openfile dot pl ampersand''' અને એન્ટર દબાવો.
+
 
+
|-
+
|  02:19
+
|  '''openfile dot pl''' ફાઈલમાં,સ્ક્રીન પર પ્રદશિત આપેલની જેમ કોડ ટાઈપ કરો. 
+
 
+
|-
+
| 02:25
+
|  ચાલો હું કોડ સમજાવું.
+
 
+
|-
+
| 02:28
+
|  The''' open''' ફંકશન વાંચવા માટે એક ફાઈલ ખોલે છે.
+
 
+
|-
+
| 02:33
+
|    પ્રથમ ડેટા ફાઈલ હેન્ડલ છે જે ભવિષ્યમાં ફાઈલ અનુસરણ કરવાની પરવાનગી આપે છે.
+
 
+
|-
+
| 02:40
+
| બીજું પેરામીટર '''<nowiki>“<”</nowiki>'''  લેસ ધેન સિમ્બોલને '''READ''' મોડ માં દર્શાવે છે.
+
 
+
|-
+
| 02:44
+
|  જો તમે  '''Mode''',  સ્પષ્ટ કરવામાં ચૂંકી જાવ તો ડીફોલ્ટ રૂપે ફાઈલ  “READ” મોડમાં ખોલવામાં આવશે.
+
 
+
|-
+
| 02:50
+
|  ત્રીજું પેરામીટર  '''first.txt'''  એ ફાઈલનું નામ છે જ્યાંથી ડેટા વાંચવાનું છે.
+
 
+
|-
+
| 02:57
+
|  શું થશે જો '''first.txt'''  ફાઈલ અસ્તિત્વના હોય ?
+
 
+
|-
+
| 03:02
+
| સ્ક્રીપ્ટનો યોગ્ય '''error message''' સાથે અંત થશે ''' dollar exclamation ($!)''' વેરીએબલમાં સંગ્રહિત થશે.
+
+
|-
+
|  03:08
+
|  '''while ''' લૂપ  લાઈન બાઈ લાઈન વાંચશે અને ત્યાં શુધી  '''<nowiki> <</nowiki>DATA>''' ફાઈલને લૂપ કરશે જ્યાં સુધી બધી ફાઈલ વાચી ના લેવાય.
+
 
+
|-
+
| 03:17
+
|  '''Print dollar underscore''' ('$_') વેરીએબલ વર્તમાન લાઈનની વિષય વસ્તુને પ્રિન્ટ કરશે.
+
 
+
|-
+
|  03:22
+
| છેલ્લે ''' FILEHANDLE'''  નામના સાથે ફાઈલને બંદ કરો જે આપણે  ઓપન સ્ટેટમેન્ટ માં આપ્યું હતું.
+
 
+
|-
+
|  03:29
+
| ફાઈલને બંદ કરવું કન્ટેન્ટનું  ઓવરરાઈટ  થવું અથવા ફાઈલના કોઈ પણ આકસ્મિક બદલાવોને રોકે છે.
+
 
+
|-
+
|  03:36
+
|  હવે ફાઈલને સેવ કરવા માટે ''' Ctrl+S''' to ''' દબાવો.
+
 
+
|-
+
|  03:40
+
|  ચાલો પ્રોગ્રામને એક્ઝીક્યુટ કરીએ.
+
 
+
|-
+
| 03:42
+
| ટર્મિનલ પર જાવ અને ટાઈપ કરો '''perl openfile dot pl''' અને એન્ટર દબાવો.
+
 
+
|-
+
|  03:51
+
|  આઉટપુટ આપેલની જેમ દ્રશ્યમાન છે.
+
 
+
|-
+
| 03:54
+
|  આ તેજ કન્ટેન્ટ છે જે આપણે  '''first dot txt ''' ફાઈલમાં પહેલા જોયું હતું.
+
 
+
|-
+
|  03:59
+
| આગળ આપણે જોશું ફાઈલમાં ડેટા કેવી રીતે લખવા.
+
 
+
|-
+
| 04:03
+
|  ''greater than''' (>) સિમ્બોલ ના સાથે ઓપન સ્ટેટમેન્ટ  '''WRITE''' મોડમાં યાખ્યાયિત કરે છે.
+
 
+
|-
+
| 04:08
+
|  ફાઈલનેમ તે ફાઈલના નામને બતાડે છે જે ડેટા લખવાનું છે.
+
|-
+
|  04:13
+
|    ચાલો હું પહેલથી જ  સેવ કરેલ  '''writefile.pl''' સેમ્પલ પ્રોગ્રામને ખોલું.
+
 
+
|-
+
| 04:19
+
|    '''terminal.''' પર જાવ.
+
 
+
|-
+
|  04:21
+
|  હવે ટાઈપ કરો ''' gedit writefile dot pl ampersand''' અને એન્ટર દબાવો.
+
 
+
|-
+
|  04:29
+
|  '''writefile dot pl''' ફાઈલમાં સ્ક્રીન પર પ્રદશિત આપેલની જેમ કોડ ટાઈપ કરો.
+
 
+
|-
+
| 04:34
+
|  ચાલો હું કોડ સમજાવું.
+
 
+
|-
+
| 04:37
+
| '''open''' ફંકશન '''second.txt'''  ફાઈલને "write" મોડ માં ખોલે છે.
+
 
+
|-
+
| 04:44
+
|  ફાઈલ નેમના પહેલા “>” - ''' Greater than''' સિમ્બોલ "write" મોડ ને દેખાડે છે.
+
 
+
|-
+
| 04:49
+
| પ્રથમ પેરામીટર "FILE1" ''' FILEHANDLE''' છે.
+
 
+
|-
+
| 04:53
+
|  પ્રિન્ટ ફંકશન આપેલ ટેક્સ્ટને ''' FILEHANDLE''' એટલેકે 'FILE1' પર પ્રિન્ટ કરે છે.
+
+
|-
+
| 04:59
+
| હવે ફાઈન ને સેવ કરવા માટે  ''' Ctrl+S'''  દબાવો.
+
 
+
|-
+
|  05:03
+
| ચાલો પ્રોગ્રામ એક્ઝીક્યુટ કરીએ.
+
 
+
|-
+
| 05:05
+
|ટર્મિનલ પર જાવ અને ટાઈપ કરો '''perl writefile dot pl'''  અને એન્ટર દબાવો.
+
 
+
|-
+
|  05:12
+
|  Now, let us check whether the text has been written in 'second.txt' file.
+
 
+
|-
+
| 05:18
+
|  Type:''' gedit second.txt''' and press '''Enter'''.
+
 
+
|-
+
|  05:23
+
|  We can see the text: "Working with files makes data storage and retrieval a simple task!" in our 'second.txt' file.
+
 
+
|-
+
|05:32
+
|  Let us close the 'second.txt' file.
+
 
+
|-
+
|  05:35
+
|  What will happen if we open the same file again in "write" mode?  Let us see that.
+
|-
+
|  05:41
+
| In the 'writefile.pl', ''' comment'''  the previous '''print''' Statement.
+
 
+
|-
+
| 05:46
+
|  Add the below '''print''' command.
+
 
+
|-
+
|  05:48
+
|  Now, press''' Ctrl+S''' to ''' save'''  the file.  Let us execute the program.
+
 
+
|-
+
|  05:54
+
|  Switch back to the terminal and type '''perl writefile dot pl''' and press''' Enter'''.
+
 
+
|-
+
|  06:00
+
|  Now, let us check the 'second.txt' file once again.
+
 
+
|-
+
|  06:04
+
|  Type: ''' gedit second.txt''' and press '''Enter'''.
+
 
+
|-
+
| 06:09
+
|  We can see the output: “Greater than symbol (>) overwrites the content of the file!"
+
 
+
|-
+
| 06:14
+
|  The previous contents of the 'second.txt' file has been overwritten.
+
 
+
|-
+
| 06:19
+
|  This is because, we had opened the file in the "write" mode again.
+
 
+
|-
+
| 06:24
+
| Let us close the 'second.txt' file.
+
 
+
|-
+
|  06:27
+
|  Next, we will see how to append data to an existing file.
+
 
+
|-
+
|  06:32
+
|  The '''open '''statement with two '''greater than''' (>>) symbols denotes the "APPEND" mode.
+
 
+
|-
+
|  06:38
+
|  Now I will open the '''writefile dot pl''' again in '''gedit'''.
+
 
+
|-
+
| 06:44
+
| In the '''open''' statement, type two '''greater (>>) than''' symbols. This will denote that the file is in '''append mode.'''
+
 
+
|-
+
|  06:52
+
|''' Comment'''  the previous '''print''' statement, as it is already executed.
+
 
+
|-
+
|  06:57
+
|  Add the line: '''print FILE1''' within double quotes "Two greater than symbols (>>) open the file in append mode", to append to the existing data.
+
 
+
|-
+
|  07:07
+
|  Now, press''' Ctrl+S''' to '''save''' the file.
+
 
+
|-
+
|  07:11
+
|  Let us '''execute''' the program.
+
 
+
|-
+
|  07:14
+
|  Switch back to the '''terminal''' and type: '''perl writefile dot pl''' and press''' Enter'''.
+
 
+
 
|-
 
|-
 
|  07:20
 
|  07:20
| Now, let us check whether the text has been appended to the 'second.txt' file.
+
|   હવે તપાસીએ કે '''second.txt''' ફાઈલ પર ટેક્સ્ટ ઉમેર્યો છે કે નહી.
  
 
|-
 
|-
 
| 07:26
 
| 07:26
Type: ''' gedit second.txt''' and press '''Enter'''.
+
ટાઈપ કરો: ''' gedit second.txt''' અને એન્ટર દબાવો.
  
 
|-
 
|-
 
|  07:31
 
|  07:31
We can see the text has been appended in our 'second.txt' file.
+
| આપણે જોઈ શકીએ છીએ કે ટેક્સ્ટ આપણી '''second.txt''' ફાઈલ  માં ઉમેરાયું છે .
  
 
|-
 
|-
 
| 07:36
 
| 07:36
| Let us close the 'second.txt' file.
+
|ચાલો '''second.txt''' ફાઈલ ને બંદ કરો.
  
 
|-
 
|-
 
|  07:39
 
|  07:39
Similarly, there are other modes also.
+
તેજ પ્રકારે અન્ય મોડ પણ છે.
  
 
|-
 
|-
 
| 07:42
 
| 07:42
| Try out these options on your own and understand what happens.
+
|   પોતે થી આ વિકલ્પોનો પ્રયાસ કરો અને સમઝો કે શું થાય છે.
  
 
|-
 
|-
 
|  07:49
 
|  07:49
| This brings us to the end of this tutorial. Let us summarize.
+
| અહી આ ટ્યુટોરીયલ સમાપ્ત થાય છે. ચાલો સારાંશ લઈએ.
  
 
|-
 
|-
 
|  07:53
 
|  07:53
In this tutorial, we learnt to:  
+
આ ટ્યુટોરીયલ માં આપણે શીખ્યા:  
* Open a file in "read" mode
+
* ફાઈલને "read" માં ખોલવી
* Write to a file
+
* ફાઈલ પર લખવું.
* Open a file in "append" mode and
+
* "append" મોડ માં ફાઈલ ને ખોલવી અને
* Close the '''file handle'''.
+
* '''file handle''' ને બંદ કરવું.
  
 
|-
 
|-
 
|  08:03
 
|  08:03
Here is an assignment for you. Change the '''file attribute''' to "+>" in the 'writefile.pl' program.
+
અહીં તમારા માટે એક એસાઇનમેંટ છે . 'writefile.pl' પ્રોગ્રામ માં  '''file attribute''' to "+>" સિમ્બોલ ને બદલો.
  
 
|-
 
|-

Revision as of 15:26, 22 January 2016

Time Narration
00:01 PERL. માં File Handling પરના આ સ્પોકન ટ્યુટોરીયલમાં સ્વાગત છે.
00:06 આ ટ્યુટોરીયલમાં આપણે આપણે શીખીશું:
  • read mode માં ફાઈલ ખોલવી
  • ફાઈલ કેવી રીતે લખવી
  • append mode માં ફાઈલ ખોલવી
  • file handle ને કેવી રીતે બંદ કરવી.
00:17 આ ટ્યુટોરીયલ માટે હું ઉપયોગ કરી રહી છું:
  • Ubuntu Linux 12.04 operating system
  • Perl 5.14.2 અને
  • gedit ટેક્સ્ટ એડિટર .
00:28 તમે તમારી પસંદગી અનુસાર કોઈ પણ ટેક્સ્ટ એડિટર વાપરી શકો છો.
00:32 આ ટ્યુટોરીયલના અનુસરણ માટે તમને ' Perl પ્રોગ્રામિંગ વિષે સામાન્ય જાણકારી હોવી જોઈએ.
00:37 જો નથી તો સ્પોકન ટ્યુટોરિયલ વેબ સાઈટ પર ઉપલબ્ધ Perl ટ્યુટોરિયલ જુઓ.
00:43 મૂળભૂત ઓપરેશન જે આપણે પર્લમાં ફાઈલ્સ સાથે કરી શકીએ છીએ તે છે:
  • ફાઈલ ખોલવી
  • ફાઈલમાં થી વાંચવું.
  • ફાઈલ પર લખવું.
  • ફાઈલ બંદ કરવી.
00:54 file handles are: મૂળભૂત file handles છે.
  • STDIN
  • STDOUT
  • STDERR
01:02 open ફંકશન માટે સિન્ટેક્સ છે.
01:05 સિન્ટેક્સમાં FILEHANDLE એ ફાઈલ હેન્ડલ છે જે open ફંકશન થી રીટર્ન થાય છે.
01:11 MODE ફાઈલ ખોલવું જેવા: રીડ, રાઈટ વગેરે મોડ ને બતાડે છે.
01:18 EXPR એ ભૌતિક ફાઈલનનું નામ છે જે વાંચવા અને લખવામાં ઉપયોગ થાય છે.
01:27 અહી પ્રદશિતની જેમ open ફંકશન ને લખવા માટે અન્ય માર્ગ છે.
01:32 ચાલો સમઝીએ વર્તમાન ફાઈલને કેવી રીતે ખોલવી અને તેમાંથી ડેટા કેવી રીતે વાંચવા.
01:38 પ્રથમ આપણે એક ટેક્સ્ટ ફાઈલ બનાવીશું અને તેમાં અમુક ડેટા સંગ્રહીશું.ટર્મિનલ પર જાવ અને ટાઈપ કરો gedit first.txt અને એન્ટર દબાવો.
01:51 first dot txt ફાઈલમાં આપેલ ટેક્સ્ટ ટીપ કરો:
01:55 ફાઈલ ને સેવ કરીને gedit બંદ કરો.
01:59 હવે આપણે એક Perl પ્રોગ્રામ જોશું જે first.txt ફાઈલ ખોલે છે અને વિષય વસ્તુ વાંચે છે.
02:07 હવે હું openfile.pl સેમ્પલ પ્રોગ્રામ ખોલીશ. જે મેં પહેલાથી જ સેવ કરેલ છે.
02:13 ટાઈપ કરો : gedit openfile dot pl ampersand અને એન્ટર દબાવો.
02:19 openfile dot pl ફાઈલમાં,સ્ક્રીન પર પ્રદશિત આપેલની જેમ કોડ ટાઈપ કરો.
02:25 ચાલો હું કોડ સમજાવું.
02:28 The open ફંકશન વાંચવા માટે એક ફાઈલ ખોલે છે.
02:33 પ્રથમ ડેટા ફાઈલ હેન્ડલ છે જે ભવિષ્યમાં ફાઈલ અનુસરણ કરવાની પરવાનગી આપે છે.
02:40 બીજું પેરામીટર “<” લેસ ધેન સિમ્બોલને READ મોડ માં દર્શાવે છે.
02:44 જો તમે Mode, સ્પષ્ટ કરવામાં ચૂંકી જાવ તો ડીફોલ્ટ રૂપે ફાઈલ “READ” મોડમાં ખોલવામાં આવશે.
02:50 ત્રીજું પેરામીટર first.txt એ ફાઈલનું નામ છે જ્યાંથી ડેટા વાંચવાનું છે.
02:57 શું થશે જો first.txt ફાઈલ અસ્તિત્વના હોય ?
03:02 સ્ક્રીપ્ટનો યોગ્ય error message સાથે અંત થશે dollar exclamation ($!) વેરીએબલમાં સંગ્રહિત થશે.
03:08 while લૂપ લાઈન બાઈ લાઈન વાંચશે અને ત્યાં શુધી <DATA> ફાઈલને લૂપ કરશે જ્યાં સુધી બધી ફાઈલ વાચી ના લેવાય.
03:17 Print dollar underscore ('$_') વેરીએબલ વર્તમાન લાઈનની વિષય વસ્તુને પ્રિન્ટ કરશે.
03:22 છેલ્લે FILEHANDLE નામના સાથે ફાઈલને બંદ કરો જે આપણે ઓપન સ્ટેટમેન્ટ માં આપ્યું હતું.
03:29 ફાઈલને બંદ કરવું કન્ટેન્ટનું ઓવરરાઈટ થવું અથવા ફાઈલના કોઈ પણ આકસ્મિક બદલાવોને રોકે છે.
03:36 હવે ફાઈલને સેવ કરવા માટે Ctrl+S to દબાવો.
03:40 ચાલો પ્રોગ્રામને એક્ઝીક્યુટ કરીએ.
03:42 ટર્મિનલ પર જાવ અને ટાઈપ કરો perl openfile dot pl અને એન્ટર દબાવો.
03:51 આઉટપુટ આપેલની જેમ દ્રશ્યમાન છે.
03:54 આ તેજ કન્ટેન્ટ છે જે આપણે first dot txt ફાઈલમાં પહેલા જોયું હતું.
03:59 આગળ આપણે જોશું ફાઈલમાં ડેટા કેવી રીતે લખવા.
04:03 greater than' (>) સિમ્બોલ ના સાથે ઓપન સ્ટેટમેન્ટ WRITE મોડમાં યાખ્યાયિત કરે છે.
04:08 ફાઈલનેમ તે ફાઈલના નામને બતાડે છે જે ડેટા લખવાનું છે.
04:13 ચાલો હું પહેલથી જ સેવ કરેલ writefile.pl સેમ્પલ પ્રોગ્રામને ખોલું.
04:19 terminal. પર જાવ.
04:21 હવે ટાઈપ કરો gedit writefile dot pl ampersand અને એન્ટર દબાવો.
04:29 writefile dot pl ફાઈલમાં સ્ક્રીન પર પ્રદશિત આપેલની જેમ કોડ ટાઈપ કરો.
04:34 ચાલો હું કોડ સમજાવું.
04:37 open ફંકશન second.txt ફાઈલને "write" મોડ માં ખોલે છે.
04:44 ફાઈલ નેમના પહેલા “>” - Greater than સિમ્બોલ "write" મોડ ને દેખાડે છે.
04:49 પ્રથમ પેરામીટર "FILE1" FILEHANDLE છે.
04:53 પ્રિન્ટ ફંકશન આપેલ ટેક્સ્ટને FILEHANDLE એટલેકે 'FILE1' પર પ્રિન્ટ કરે છે.
04:59 હવે ફાઈન ને સેવ કરવા માટે Ctrl+S દબાવો.
05:03 ચાલો પ્રોગ્રામ એક્ઝીક્યુટ કરીએ.
05:05 ટર્મિનલ પર જાવ અને ટાઈપ કરો perl writefile dot pl અને એન્ટર દબાવો.
05:12 હવે ચાલો તપાસ કરીએ કે second.txt ફાઈલમાં ટેક્સ્ટ લખ્યું છે કે નહી.
05:18 ટાઈપ કરો: gedit second.txt અને Enter દબાવો.
05:23 ફાઈલમાં આપેલ ટેક્સ્ટ જોઈ શકીએ છીએ: "Working with files makes data storage and retrieval a simple task!"
05:32 ચાલો 'second.txt' ફાઈલને બંદ કરીએ.
05:35 શું થાય છે જયારે આપણે "write" મોડમાં સમાન ફાઈલ ફરીથી ખોલીએ છીએ ? ચાલો તેને જોઈએ.
05:41 'writefile.pl', માં પાછલા પ્રિન્ટ સ્ટેટમેન્ટ ને કમેન્ટ કરો.
05:46 નીચે વાળા પ્રિન્ટ કમાંડ ને ઉમેરીએ.
05:48 હવે ફાઈલને સેવ કરવા માટે Ctrl+S દબાવો. ચાલો પ્રોગ્રામને એક્ઝીક્યુટ કરીએ.
05:54 ટર્મિનલ પર જાવ અને ટાઈપ કરો perl writefile dot pl અને એન્ટર દબાવો.
06:00 ચાલો ફરીથી second.txt ફાઈલને ફરીથી તપાસીએ.
06:04 ટાઈપ કરો : gedit second.txt અને Enter દબાવો.
06:09 આપણે “Greater than symbol (>) overwrites the content of the file!" સિમ્બોલ જોશું.
06:14 second.txt ફાઈલના પાછલા કન્ટેન્ટ ઓવરરાઈટ થયી ગયા છે.
06:19 આવું એટલા માટે કારણકે આપણે "write" મોડમાં ફરીથી ફાઈલ ખોલી હતી.
06:24 ચાલો 'second.txt' ફાઈલ ને બંદ કરો.
06:27 આગળ આપણે જોશું કે વર્તમાન ફાઈલમાં ડેટા કેવી રીતે ઉમેરીશું.
06:32 બે greater than (>>) સિમ્બોલના સાથે ઓપન સ્ટેટમેન્ટ "APPEND" મોડને દેખાડે છે.
06:38 હવે હું ફરીથી gedit માં writefile dot pl ફાઈલ ખોલીશ.
06:44 ઓપન સ્ટેટમેન્ટ માં ટાઈપ કરો greater (>>) than' સિમ્બોલ આ બતાડશે કે ફાઈલ append mode. માં છે.
06:52 પાછલા પ્રિન્ટ સ્ટેટમેન્ટને Comment કરો જેવું કે આ પહલા એક્ઝીક્યુટ થયું છે.
06:57 વર્તમાન ડેટા ને ઉમેરવા માટે એક લાઈન ઉમેરો : print FILE1 ડબલ કોટમાં "Two greater than symbols (>>) open the file in append mode".
07:07 હવે ફાઈલ ને સેવ કરવા માટે Ctrl+S દબાવો.
07:11 ચાલો પ્રોગ્રામ ને એક્ઝીક્યુટ કરો.
07:14 ટર્મિનલ પર જાવ અને ટાઈપ કરો : perl writefile dot pl અને એન્ટર દબાવો.
07:20 હવે તપાસીએ કે second.txt ફાઈલ પર ટેક્સ્ટ ઉમેર્યો છે કે નહી.
07:26 ટાઈપ કરો: gedit second.txt અને એન્ટર દબાવો.
07:31 આપણે જોઈ શકીએ છીએ કે ટેક્સ્ટ આપણી second.txt ફાઈલ માં ઉમેરાયું છે .
07:36 ચાલો second.txt ફાઈલ ને બંદ કરો.
07:39 તેજ પ્રકારે અન્ય મોડ પણ છે.
07:42 પોતે થી આ વિકલ્પોનો પ્રયાસ કરો અને સમઝો કે શું થાય છે.
07:49 અહી આ ટ્યુટોરીયલ સમાપ્ત થાય છે. ચાલો સારાંશ લઈએ.
07:53 આ ટ્યુટોરીયલ માં આપણે શીખ્યા:
  • ફાઈલને "read" માં ખોલવી
  • ફાઈલ પર લખવું.
  • "append" મોડ માં ફાઈલ ને ખોલવી અને
  • file handle ને બંદ કરવું.
08:03 અહીં તમારા માટે એક એસાઇનમેંટ છે . 'writefile.pl' પ્રોગ્રામ માં file attribute to "+>" સિમ્બોલ ને બદલો.
08:11 Save and execute the program.
08:14 Open the 'second.txt' file to see the output.
08:17 Analyze the usage of file attribute "+>".
08:22 The video at the following link summarizes the Spoken Tutorial project. Please download and watch it.
08:29 The Spoken Tutorial Project team:
  • conducts workshops using spoken tutorials and
  • gives certificates on passing online tests.
08:37 For more details, please write to us.
08:41 Spoken Tutorial project is funded by NMEICT, MHRD, Government of India.
08:48 More information on this mission is available at this link.
08:53 This is Nirmala Venkat from IIT Bombay, signing off. Thanks for watching.

Contributors and Content Editors

Jyotisolanki, PoojaMoolya