NAME
Sys::Export::LazyFileData - Reference a path and optional range of bytes and load it on demand
SYNOPSIS
my $m= Sys::Export::LazyFileData->new($filename);
say $m; # prints contents of file
say $$m; # virtual scalar-ref, also prints contents of file
DESCRIPTION
This allows you to pass around a filename in place of file data, and automatically load the data in any context that wants it. Aside from being lazy, this object helps avoid making copies of large memory-maps by letting you pass around a reference.
CONSTRUCTORS
new
$m= Sys::Export::LazyFileData->new($filename, $offset= 0, $size= undef);
$m= Sys::Export::LazyFileData->new(\$scalar, $offset= 0, $size= undef);
Return a new object that either lazily maps/loads a range of a file, or lazily reads a range of bytes from a file, or lazily performs a 'substr' on a scalar-ref.
ATTRIBUTES
source
The source of the data; either a scalarref or filename.
abs_path
The absolute pathname from which the file data is being read. This can be undef if the file name wasn't specified in the constructor.
offset
The byte offset from which it will read
size
The number of bytes of data that will be returned (clamped to file size)
METHODS
as_string
Returns the content of the range of the file
as_scalarref
Returns the content of the range of the file as a scalar ref
VERSION
version 0.004
AUTHOR
Michael Conrad <mike@nrdvana.net>
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Michael Conrad.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.