Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Hero Zzyzzx's scratchpad

by Hero Zzyzzx (Curate)
on Jun 01, 2004 at 22:36 UTC ( #358735=scratchpad: print w/ replies, xml ) Need Help??

use Storable; use Fcntl qw(:DEFAULT :flock); sub stash_file{ my($filename,$array)=@_; # $array can be any reference. # I'm not storing in network order now, 'cuz I don't need to. # I will if I need to. sysopen(DF,"$filename", O_RDWR | O_CREAT,0666) or die("Couldn't open $filename: $!"); flock(DF,LOCK_EX) or die("Couldn't lock $filename: $!"); Storable::store_fd($array, *DF) or die("Couldn't store $filename: $!"); truncate(DF, tell(DF)); close(DF); } sub get_file{ my $filename=shift; # This restores the structure and returns it as a reference. open(DF, "< $filename") or die("Couldn't open $filename $!"); flock(DF, LOCK_SH) or die("Couldn't lock $filename $!"); my $doc = Storable::fd_retrieve(\*DF); close(DF); return $doc; }

How to Modify Only Non-Quoted Words?
Nested Categories
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2014-09-01 21:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (17 votes), past polls