Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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 chanting in the Monastery: (6)
As of 2024-10-10 20:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (45 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.