私はperlを使ってコマンドライン引数を使って入出力ファイルを渡す前の例のうちの1つをtreidしていますか?perlを使ってperlモジュールと一緒にコマンドライン引数を渡すには?
前例:
[私は、コマンドライン引数として入力および出力ファイルを追加しようとしましたIs it possible to add the file out in the File::Find::Rule using perl?
コード:(generate.pl
).Iは読んでコピーするには、コマンドライン引数を含める方法を打たれてしまいましたperlモジュールと一緒にファイルを作成します。
use strict;
use warnings 'all';
use CGI qw(:all);
#generate the user file arguments
use Getopt::Long 'GetOptions';
use File::Path qw(make_path);
use File::Copy qw(copy move);
use File::Find::Rule qw();
GetOptions(
'prjroot=s' => \my $input_dir,
'outdir=s' => \my $output_dir,
);
my %created;
for my $in (
File::Find::Rule
->file()
->name(qr/^[^.].*\.yfg$/)
->in($input_dir)
) {
my $match_file = substr($in, length($input_dir) + 1);
my ($match_dir) = $match_file =~ m{^(.*)/} ? $1 : '.';
my $out_dir = $output_dir . '/' . $match_dir;
my $out = $output_dir . '/' . $match_file;
make_path($out_dir) if !$created{$out_dir}++;
copy($in, $out);
}
にエラーが発生しました:次のように
./generate.pl: line 1: use: command not found
./generate.pl: line 2: use: command not found
./generate.pl: line 3: syntax error near unexpected token `('
./generate.pl: line 3: `use CGI qw(:all);'
perlの実行は次のようになります。
私はPerlモジュールと一緒に別のディレクトリ(IEファイル::検索に一つのディレクトリの内容をコピーする必要があります。 :ルール)
./generate.pl -prjroot "/home/bharat/DATA" -outdir "/home/bharat/DATA1"
私の問題を解決するための手助けをしてください。