File: ListFiles.pm

package info (click to toggle)
prt 0.22-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 404 kB
  • sloc: perl: 1,185; makefile: 3
file content (39 lines) | stat: -rwxr-xr-x 748 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package App::PRT::Command::ListFiles;
# Created by CXW based on App::PRT::Command::RenameClass

use strict;
use warnings;
use Path::Class;

sub new {
    my ($class) = @_;
    bless {eol => "\n"}, $class;
}

# parse arguments from CLI.  The only argument is `-0`, to output
# filenames separated by "\0" instead of "\n".
# arguments:
#   @arguments
# returns:
#   @rest_arguments
sub parse_arguments {
    my ($self, @arguments) = @_;

    if(@arguments && $arguments[0] eq '-0') {
        shift @arguments;
        $self->{eol} = "\0";
    }

    @arguments;
}

# Output the filename.
# arguments:
#   $file: filename
sub execute {
    my ($self, $file) = @_;
    print file($file), $self->{eol};
        # Extra file() call to canonicalize
}

1;