Data::Embed::File - embed arbitrary data in a file
Accessor class for representing an embedded file (for reading).
my $string = $def->contents();
Convenience method to slurp the whole contents of the embedded file in one single shot. It always provides the full contents, independently of whether data had been read before, although it restores the filehandle to the previous position.
my $fh = $def->fh();
Get a filehandle suitable for accessing the embedded file. It provides back a filehandle through IO::Slice, providing the illusion of working on a file per-se instead of a slice inside a bigger file.
$def->is_same_as($other_def);
Test whether the specific Data::Embed::File is the same as some $other_def.
$other_def
my $name = $def->name();
Get the name associated to the file, whatever it is. Data::Embed::Reader sets it from what is read in the index file
my $def = Data::Embed::File->new(%args); # OR my $def = Data::Embed::File->new(\%args);
Constructor. It will act lazily, just storing the input data for later usage by other methods, providing validation.
Input data can be provided as key-value pairs of through a reference to a hash.
For proper functioning of the object, the following keys should be provided:
fh
a filehandle for the stream where the data are contained
filename
the name of the file where the data are. This parameter is optional if fh above is already provided.
offset
the offset within the stream where the real data for this file begins. 0 means the very beginning of the file.
0
length
the length of the data belonging to this File.
File
Flavio Poletti <polettix@cpan.org>
Copyright (C) 2014-2016 by Flavio Poletti <polettix@cpan.org>
This module is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0.
This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.
To install Data::Embed, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Embed
CPAN shell
perl -MCPAN -e shell install Data::Embed
For more information on module installation, please visit the detailed CPAN module installation guide.