in reply to Re: Storable and passed filehandles
in thread Storable and passed filehandles
#!/usr/bin/perl -w # start with no existing giant.db file use strict; use Fcntl qw(:DEFAULT :flock); use Storable qw(store_fd fd_retrieve retrieve); use Data::Dumper; $Data::Dumper::Deepcopy=1; $Data::Dumper::Purity=1; $Data::Dumper::Sortkeys=1; my %data = ( 1 => 'FEE', 2 => 'FYE', 3 => 'FOH', 4 => 'FUM', ); sysopen(*DB, "giant.db", O_RDWR|O_CREAT, 0666) or die("sysopen: $!\n") +; flock(*DB, LOCK_EX) or die("flock: $!\n"); my $hashref = fd_retrieve(*DB); # modify the data, do work, etc.. $hashref->{$_} = $data{$_} for sort keys %data; store_fd($hashref, *DB) or die("store_fd: $!\n"); truncate(*DB, tell(*DB)); close(*DB);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Storable and passed filehandles
by Roger (Parson) on Aug 15, 2005 at 23:26 UTC | |
by blahblah (Friar) on Aug 15, 2005 at 23:33 UTC | |
|
Re^3: Storable and passed filehandles (ref to glob)
by tye (Sage) on Aug 15, 2005 at 23:27 UTC | |
by blahblah (Friar) on Aug 15, 2005 at 23:30 UTC | |
by tye (Sage) on Aug 16, 2005 at 00:40 UTC | |
by blahblah (Friar) on Aug 16, 2005 at 01:21 UTC | |
by tye (Sage) on Aug 16, 2005 at 01:36 UTC | |
|