++ed by:
SHARYANTO PERLANCAR

2 PAUSE users

David F. Houghton

NAME

TPath::Forester::File::Attributes - the basic attributes of TPath::Forester::File::Node objects

VERSION

version 0.003

DESCRIPTION

TPath::Forester::File::Attributes provides the attributes available to all TPath::Forester::File foresters.

@text

The actual text of the file, if it is a text file, or undef.

@txt

An alias for @txt.

@T

Whether the file is a text file according to 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.

@oid

File owner id. This would be called @uid, but that attribute name is already taken by the standard attribute library.

@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.

@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)]

instead of

  //@f[@size > 12 * 1024 * 1024]

or

  //@f[@size > 12582912]

There is a slight efficiency cost in using @mb, as the conversion will be done for every file tested.

@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)]

instead of

  //@f[@size > 12 * 1024 * 1024 * 1024]

or

  //@f[@size > 12884901888]

There is a slight efficiency cost in using @gb, as the conversion will be done for every file tested.

@me

The real user id of the currently running process; i.e., <$<>.

ATTRIBUTES

@broken

True if stat returns the empty list for this file.

@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.

@name

The file (or directory) name.

@encoding, @enc

Encoding detected, if any.

AUTHOR

David F. Houghton <dfhoughton@gmail.com>

COPYRIGHT AND LICENSE

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.