Thread Hash-Inhalt auf Festplatte speichern (26 answers)
Opened by der_thomas at 2013-09-21 17:43

topeg
 2013-09-22 14:03
#170481 #170481
User since
2006-07-10
2611 Artikel
BenutzerIn

user image
CPAN:DB_File
Einfach zu benutzen und ist im Core. Die Datei ist nicht ASCII sondern das BerkleyDB Format Version1.

Ein kleines einfaches Beispiel:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/perl
use DB_File;
use strict;
use warnings;

my $db_file="data.db";

# @array an das Modul "DB_File" binden
tie( my @data, "DB_File", $db_file, O_RDWR|O_CREAT, 0666, $DB_RECNO) or die "ERROR open $db_file: $!\n";

# erster Durchlauf
# Array befüllen
@data=qw( nur ein kleiner Test ) if(!@data);

# Ausgabe des Arrays
print join(" ",@data)."\n";

# Array zu Testzwecken rotieren
push(@data,shift(@data));


Das Modul beherrscht das tie-Interface damit kann man das Modul an eine Variable binden und diese normal nutzen. Perl macht den Rest selbstständig im Hintergrund ( lesen/schreiben/aktualisieren )

View full thread Hash-Inhalt auf Festplatte speichern