私はそうのように見えますlist.txt
というファイルがあります(それは500以上の行を持つ)たPerl:で始まる行を指定するためにどのように「/」
/apps/gtool/0.7.5/gtool -M --g gen1.txt etc
/apps/gtool/0.7.5/gtool -M --g gen2.txt etc
/apps/gtool/0.7.5/gtool -M --g gen3.txt etc
私はそれぞれの行と.SHスクリプトを作りたいですlist.txt。私はエラーを取得する
use strict;
use warnings;
open (IN, "<list_for_merging_chunks.sh");
while (<IN>)
{
if ($_=~ m/^/apps.*\n/)
{
my $file = $_;
$file =~ s/.*\> //;
$file =~ s/\.txt/.sh/;
$file =~ s/\n//;
open (OUT, ">$file");
print OUT "\#!/bin/bash\n\#BSUB -J \"$file\"\n\#BSUB -o
/scratch/home/\n\#BSUB -e /scratch/home/$file\.out\n#BSUB -n 1\n\#BSUB -q
normal\n\#BSUB -P DBCDOBZAK\n\#BSUB -W 168:00\n";
print OUT $_;
close OUT;
}
}
exit;
:私はPerlでこれを行うことができますが、私は次のように私のスクリプトがどのように指名ラインが/
で始まるかわからないように私はこの問題を持っている
をBareword found where operator expected at merging_chunks.pl line 7, near "*\n"
(Missing operator before n?)
"my" variable $file masks earlier declaration in same statement at
merging_chunks.pl line 10.
"my" variable $file masks earlier declaration in same scope at
merging_chunks.pl line 11.
"my" variable $file masks earlier declaration in same scope at
merging_chunks.pl line 12.
"my" variable $file masks earlier declaration in same scope at
merging_chunks.pl line 14.
"my" variable $file masks earlier declaration in same scope at
merging_chunks.pl line 15.
"my" variable $file masks earlier declaration in same statement at
merging_chunks.pl line 15.
"my" variable $file masks earlier declaration in same statement at
merging_chunks.pl line 15.
"my" variable $_ masks earlier declaration in same scope at merging_chunks.pl
line 16.
syntax error at merging_chunks.pl line 7, near "*\n"
syntax error at merging_chunks.pl line 20, near "}"
Execution of merging_chunks.pl aborted due to compilation errors.
私がこのファイルをどうするだと思う:if ($_=~ m/^/apps.*\n/)
それはそれは/
で始まるという事実を好きにいないようです。とにかく私はこれを回避することができますか?私は何とかPerlに伝えるために使うことができる特殊文字があると仮定していますか?どうもありがとう。