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 ( [id://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
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-20 01:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found