[Chicago-talk] Using Storable to exchange data between 2 processes
Steven Lembark
lembark at wrkhors.com
Fri Jan 23 17:25:52 CST 2004
-- Don Drake <don at drakeconsult.com>
>
> I would modify the child to write to a temp file, then rename it to the
> real file. The 'mv' command in Unix is an atomic call, so you'll never
> have a file in an inconsistent state (partially written). The rename
> function is portable, but has known issues when renaming across file
> systems, etc. on certain platforms.
>
> -Don
>
>
>
> sub child {
>
> foreach (0..60) {
> sleep 1;
> $data{IBM}{last} = $_;
> store(\%data,'/tmp/jstrauss.tmp');
> rename ('/tmp/jstrauss.tmp','tmp/jstrauss');
> # or if you're running unix:
> # system("/bin/mv -f /tmp/jstrauss.tmp /tmp/jstrauss");
> }
> }
Even easier: use File::Temp.
--
Steven Lembark 2930 W. Palmer
Workhorse Computing Chicago, IL 60647
+1 888 359 3508
More information about the Chicago-talk
mailing list