Thread serial, dump - Komplexe Datenstrukturen speichern und ausgeben
(12 answers)
Opened by mika at 2012-03-03 14:55
Komprimiertes Archiv. Ist ungetestet:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 #!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Storable qw(store_fd fd_retrieve); use IO::Zlib; my $path = "/tmp/file"; my %hash = (name => "Mika", age => 30); # <-- fest-codierte Werte! my $hash = ( -r $path)? fd_retrieve(IO::Zlib->new($path, "rb")) : \%hash; print Dumper($hash); # neues zufälliges wertepaar $hash->{join('',map{chr(int(rand(25))+65)}(1..4))}=int(rand(50)); store_fd ($hash, IO::Zlib->new($path, "wb")); Last edited: 2012-03-04 08:47:01 +0100 (CET) |