1AnyData::Storage::File(U3s)er Contributed Perl DocumentatAinoynData::Storage::File(3)
2
3
4
6 AnyData::Storage::File -- manipulate files with rich warnings
7
9 Opens, reads from, writes to, creates and destroys files with numerous
10 options for error handling, flocking, binmode, etc.
11
12 The simplest form is the equivalent of
13
14 my $f = AnyData::Storage::File->new(dirs=>\@dirs,flock=>1);
15 my $str1 = $f->adSlurp($file);
16
17
18 for( @dirs ) {
19 open(IN,$file) or die $!;
20 }
21 sub slurp {
22 local *IN;
23 local $/ = undef;
24 }
25
26 But, depending on how you set the default behaviour
27
29 use AnyData;
30 my $f = AnyData::Storage::File->new;
31 $f->set('binmode',1|0);
32 $f->set('PrintError',1|0);
33 $f->set('RaiseError',1|0);
34 $f->set('Trace',1|0);
35 $f->set('f_dir',$dir|$dir_array)
36
37 < input, fail if doesn't exist > output, truncate if exists, create
38 if doesn't >> append, create if doesn't exist +< read/write, fail if
39 doesn't exist
40
41 r = < r+ =
42
44 my $f = AnyData::Storage::File->new;
45
46 or
47
48 my $f = AnyData::Storage::File->new( %flags );
49
50 %flags is a hash which can contain any or all of:
51
52 f_dir => $directory, # defaults to './' (
53 binmode => $binmode, # defaults to 0 (doesn't binmode files)
54 printError => $warnings, # defaults to 1 (print warning on errors)
55
57 Mode is one of
58
59 a = append open for reading & writing, create if doesn't exist
60 r = read open for reading, fail if doesn't exist
61 u = open open for reading & writing, fail if doesn't exist
62 c = create open for reading & writing, fail if it already exists
63 o = overwrite open for reading & writing, overwrite if it already exists
64
65 Additionally, all modes fail if the file can't be opened. On systems
66 that support flock, 'r' fails if a shared lock can not be obtained; the
67 other modes fail if an exclusive lock can't be obtained.
68
69
70
71perl v5.30.1 2020-01-29 AnyData::Storage::File(3)