Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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 imbibing at the Monastery: (5)
As of 2014-07-23 03:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (132 votes), past polls