Perlでfindを呼び出すときにエラーが発生しました。

Perlでfindを呼び出すときにエラーが発生しました。
use warnings;
use File::Find;

my $srceDir = "//mnt/Share_Drive/Verizon PM&T/Capture Files/";
opendir(DIR, $srceDir) or die "Can't open $srceDir: $!";
my @files = (find -type f -newermt "12 Feb 2013", $srceDir);
closedir(DIR);

findこのオプションを使用してLinuxでコマンドを実行できますが、-newermtPerlスクリプトに入れると次のエラーが発生します。助けてもらえますか?ありがとう

String found where operator expected at ./queryAlm.pl line 11, near "newermt "12 Feb 2013""
  (Do you need to predeclare newermt?)
syntax error at ./queryAlm.pl line 11, near "newermt "12 Feb 2013""

ベストアンサー1

PerlFile::Findモジュールはこのコマンドとほとんど関係ありませんfindperldoc File::Find使用方法を確認してください。

jordanmが指摘したように、これはコードを書くのに役立ちますが、find2perl標準構文だけを認識するため、通常はBSD / GNU拡張は認識されません。たとえば、Perlコードを直接書く必要があります。 (対応するファイルを呼び出してCompareで実行します)。perlfind2perlfind-newermtstat()mtimePOSIX::mktime(0,0,0,12,2,113)

findモジュールが不要なコマンドを実行するには、File::Find次のようにします。

my $srceDir = "//mnt/Share_Drive/Verizon PM&T/Capture Files/";
my @find_cmd = ("find", $srceDir, "-type", "f", "-newermt", "12 Feb 2013", "-print0");

open FIND, "-|", @find_cmd;
$/ = "\0";
my @files = <FIND>; chomp @files;
my $ret = close FIND or warn $! ?
    "Error closing find pipe: $!" :
    "find exited with non-zero exit status: $?";

おすすめ記事