HTML::Object::DOM::File - HTML Object DOM File Class
use HTML::Object::DOM::File; my $file = HTML::Object::DOM::File->new || die( HTML::Object::DOM::File->error, "\n" );
v0.2.0
The File interface provides information about files and allows access to their content.
File
File objects are generally retrieved from a HTML::Object::DOM::FileList object returned using the <input> files method.
<input
It inherits from Module::Generic::File
Read-only.
Returns the last modified time of the file, in second since the UNIX epoch (January 1st, 1970 at Midnight), as a Module::Generic::DateTime object. The DateTime object stringifies to the seconds since epoch.
See Mozilla documentation
Returns the last modified date and time of the file referenced by the file object, as a Module::Generic::DateTime object.
Returns the name of the file referenced by the file object.
Returns the relative file path.
Normally under JavaScript, this works alongside the <input> attribute webkitdirectory:
webkitdirectory
<input type="file" webkitdirectory />
allowing a user to select an entire directory instead of just files. So, webkitRelativePath provide the relative file path to that directory uploaded.
webkitRelativePath
Returns the size of the file in bytes.
Returns the MIME type of the file, or undef if it cannot find it.
undef
Opens the file as raw data and returns its content as a scalar object.
raw
Provided with a start and an end as a range, and an optional encoding and this will return that range of data from the file, as a scalar object. If no encoding is provided, this will default to utf-8
start
end
utf-8
If you specify a negative start, it is treated as an offset from the end of the file's data toward the beginning. For example, -10 would be the 10th from last byte in the file data. The default value is 0. If you specify a value for start that is larger than the size of the file, the returned scalar object has size 0 and contains no data.
-10
10th
0
The end specifies the offset (not the length) of the last byte, without including it, to include in the returned data. If you specify a negative end, it is treated as an offset from the end of the data toward the beginning. For example, -10 would be the 10th from last byte in the file's data. The default value is the file size, i.e. until the end of the file's data.
size
Returns a new scalar object containing the data in the specified range of bytes of the file.
This opens the file and returns its file handle to read the file's contents. You could also do:
my $io = $file->open || die( $file->error );
Opens the file in utf-8 and returns its content as a scalar object.
Jacques Deguest <jack@deguest.jp>
Mozilla documentation
Copyright(c) 2021 DEGUEST Pte. Ltd.
All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install HTML::Object, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTML::Object
CPAN shell
perl -MCPAN -e shell install HTML::Object
For more information on module installation, please visit the detailed CPAN module installation guide.