<?xml version="1.0" encoding="windows-1252"?>
<node id="1005142" title="Re: Thread safe equivalent of LINUX touch command" created="2012-11-22 09:59:24" updated="2012-11-22 09:59:24">
<type id="11">
note</type>
<author id="733061">
flexvault</author>
<data>
<field name="doctext">
&lt;p&gt;&lt;a href="http://www.perlmonks.org/?node_id=448607"&gt;ISAI student&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;I have a common module that includes the following:
&lt;code&gt;
 sub Touch
 { my $file = shift;
   open ( my $TOUCH,"&gt;&gt;",$file ) || Die_Rtn( 23, "$Caller: ! open failure on |$file|");
   close $TOUCH;
  }
&lt;/code&gt;&lt;/p&gt;&lt;p&gt;
In your code you call it the same way as you do now. Make sure you have the "&gt;&gt;" or you'll clear the file. Note: On some older *nix systems, I've had to actually do I/O to the file. In that case, I'd 'print' a "\n" to the end before closing. I  didn't like that solution, but it did work and didn't cause any *KNOWN* problems.
&lt;/p&gt;&lt;p&gt;


I have used mostly 'fork', so I've never tried this with Threads, so others may suggest an alternative, but this works and is faster than calling the system 'touch'.
'Die_Rtn' is also in the common module and determines if the failure is for the user or the system and acts accordingly.

&lt;/p&gt;
&lt;p&gt;Hope this helps!&lt;/p&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-733061"&gt;
&lt;p&gt;&lt;b&gt;"Well done is better than well said." - Benjamin Franklin&lt;/b&gt;&lt;/p&gt;

&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1005135</field>
<field name="parent_node">
1005135</field>
</data>
</node>
