AnyDat...::File(3pm)
π AnyDat...::File π
okay bestie, welcome to AnyDat...::File(3pm), straight outta the User Contributed Perl Documentation β¨ grab a snack, we're doing file storage today.
β¨ NAME β¨
AnyData::Storage::File β manipulate files with rich warnings π
π¦ DESCRIPTION π¦
So the whole vibe here? It opens, reads from, writes to, creates and destroys files, with numerous options for error handling, flocking, binmode, etc. It's giving β¨main character file handlingβ¨.
The simplest form is the equivalent of:
my $f = AnyData::Storage::File->new(dirs=>\@dirs,flock=>1);
my $str1 = $f->adSlurp($file);
for( @dirs ) {
open(IN,$file) or die $!;
}
sub slurp {
local *IN;
local $/ = undef;
}
But, depending on how you set the default behaviourβ¦ π (and yeah, the sentence really does just end there, iconic honestly, we respect a cliffhanger π )
πΈ SYNOPSIS πΈ
use AnyData;
my $f = AnyData::Storage::File->new;
$f->set('binmode',1|0);
$f->set('PrintError',1|0);
$f->set('RaiseError',1|0);
$f->set('Trace',1|0);
$f->set('f_dir',$dir|$dir_array)
and then the mode legend, no cap, exactly like this:
< input, fail if doesn't exist > output, truncate if exists, create if
doesn't >> append, create if doesn't exist +< read/write, fail if
doesn't exist
r = < r+ =
not me staring at that last line for a full minute π it's verbatim, bestie, we don't edit the lore.
π new() π
my $f = AnyData::Storage::File->new;
or
my $f = AnyData::Storage::File->new( %flags );
%flags is a hash which can contain any or all of:
f_dir => $directory, # defaults to './' (
binmode => $binmode, # defaults to 0 (doesn't binmode files)
printError => $warnings, # defaults to 1 (print warning on errors)
(and yes, './' ( really is chillin' there with an unclosed paren, periodt β we keep it exactly how it came π«Ά)
π open_local_file( $fname, $mode ); π
Mode is one of:
a= append β open for reading & writing, create if it doesn't exist πr= read β open for reading, fail if it doesn't exist πu= open β open for reading & writing, fail if it doesn't exist πc= create β open for reading & writing, fail if it already exists πo= overwrite β open for reading & writing, overwrite if it already exists π₯
Additionally, all modes fail if the file can't be opened. On systems that support flock, 'r' fails if a shared lock can not be obtained; the other modes fail if an exclusive lock can't be obtained. So likeβ¦ lock your files, bestie, it's a whole boundary thing π
and that's the whole page!! this lil gem is AnyDat...::File(3pm), perl v5.36.0, dated 2023-08-06 β go forth and file-manipulate responsibly, ily, bye π§π
π¦ where this page comes from
- debian trixie: libanydata-perl 0.12-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libanydata-perl 0.12-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu questing: libanydata-perl 0.12-3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms