TPath::Forester::File::Attributes - the basic attributes of TPath::Forester::File::Node objects
version 0.003
TPath::Forester::File::Attributes provides the attributes available to all TPath::Forester::File foresters.
TPath::Forester::File::Attributes
@text
The actual text of the file, if it is a text file, or undef.
undef
@txt
An alias for @txt.
@T
Whether the file is a text file according to TPath::Forester::File::Node::is_text().
TPath::Forester::File::Node::is_text()
@bin
Like @B but true only for files, not directories.
@B
Equivalent to the -B file test operator. True for binary files, empty files, and directories.
-B
@oid
File owner id. This would be called @uid, but that attribute name is already taken by the standard attribute library.
@uid
@gid
File group id.
@user
Returns the name corresponding to the file's uid.
//*[@user = 'foo'] # find all foo's files
@group
Returns the name corresponding to the file's gid.
//*[@group = 'research'] # find all the files belonging to the research group
@lines
The lines in the file returned as an array reference. If the file is not a text file, this will be an empty array.
@exec('rm -rf _')
Executes the command parameter, replacing _ with the context file. For example, the following will remove all text files from a directory:
_
//@txt[@exec('rm -rf _')]
Anything printed to STDOUT is captured and returned as the value of the attribute, the empty string being returned as undef.
@kb(2)
Converts a number to a number of kilobytes. This saves doing the conversion oneself, so you can write expressions like
//@f[@size > @kb(12)]
instead of
//@f[@size > 12 * 1024]
or
//@f[@size > 12288]
There is a slight efficiency cost in using @kb, as the conversion will be done for every file tested.
@kb
@mb(2)
Converts a number to a number of megabytes. This saves doing the conversion oneself, so you can write expressions like
//@f[@size > @mb(12)]
//@f[@size > 12 * 1024 * 1024]
//@f[@size > 12582912]
There is a slight efficiency cost in using @mb, as the conversion will be done for every file tested.
@mb
@gb(2)
Converts a number to a number of gigabytes. This saves doing the conversion oneself, so you can write expressions like
//@f[@size > @gb(12)]
//@f[@size > 12 * 1024 * 1024 * 1024]
//@f[@size > 12884901888]
There is a slight efficiency cost in using @gb, as the conversion will be done for every file tested.
@gb
@me
The real user id of the currently running process; i.e., <$<>.
<$<
@broken
True if stat returns the empty list for this file.
stat
@ext('txt')
True if the file has the given extension. The following are equivalent
//@ext('txt') //~\.txt$~ //*[@name =| '.txt']
The latter is second shorter but also more cryptic. In its implementation @ext is more like the last expression, but it applies the test on selection rather than filtering.
@ext
@name
The file (or directory) name.
@encoding
@enc
Encoding detected, if any.
David F. Houghton <dfhoughton@gmail.com>
This software is copyright (c) 2013 by David F. Houghton.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install TPath::Forester::File, copy and paste the appropriate command in to your terminal.
cpanm
cpanm TPath::Forester::File
CPAN shell
perl -MCPAN -e shell install TPath::Forester::File
For more information on module installation, please visit the detailed CPAN module installation guide.