1
嗨,我新來stackoverflow。我試圖尋找一種方法來打印另一個perl腳本內的另一個perl腳本,我遇到的唯一的建議是使用反斜槓轉義變量......但我試過這個,它不起作用。在另一個perl腳本中打印perl腳本?
我的目標是編寫一個perl腳本來製作一堆新的perl腳本,但是因爲它不允許我在print「」中使用變量/ arrays/etc。有沒有解決的辦法?提前致謝!
這是我初步的腳本:
#!/usr/bin/perl
use warnings;
use strict;
my $idfile = $ARGV[0];
open (IDFILE,'<',$idfile)
or die "Could not open $idfile \n";
my $outfile_name;
my $outfile = $outfile_name."pl";
open (OUTFILE, '>', $outfile)
or die "Could not open $outfile \n";
while (my $line = <IDFILE>) {
chomp ($line);
if ($line =~ /(T4-GC_[0-9]+)/) {
my $outfile_name = "Pull_".$line;
my $script = "
#!/usr/bin/perl
use warnings;
use strict;
use Bio::SearchIO;
use Bio::SeqIO;
my @ARGV = glob("*.fa");
foreach my $fil (@ARGV) {
my $seqio = Bio::SeqIO->new(-format => 'fasta', -file => $fil);
while (my $seqobj = $seqio->next_seq) {
my $seqid = $seqobj->display_id;
$fil =~ /([A-Z]+[0-9]+)/;
my $phage_name = $1;
my $id = $seqid."|".$phage_name;
my $nuc = $seqobj->seq();
if ($seqid =~ /**$line**/) {
print ">$id\n$nuc\n";
}
}
}"
print OUTFILE $script;
}
}
這是我回來的錯誤:
String found where operator expected at make_perl_pull_genes_files.pl line 33, near "my $id = $seqid.""
(Might be a runaway multi-line "" string starting on line 25)
(Missing semicolon on previous line?)
Backslash found where operator expected at make_perl_pull_genes_files.pl line 36, near "$id\"
(Might be a runaway multi-line "" string starting on line 33)
(Missing operator before \?)
Backslash found where operator expected at make_perl_pull_genes_files.pl line 36, near "$nuc\"
(Missing operator before \?)
String found where operator expected at make_perl_pull_genes_files.pl line 39, near "}""
(Might be a runaway multi-line "" string starting on line 36)
(Missing semicolon on previous line?)
syntax error at make_perl_pull_genes_files.pl line 25, near "*."
(Might be a runaway multi-line "" string starting on line 18)
Global symbol "$id" requires explicit package name at make_perl_pull_genes_files.pl line 36.
Global symbol "$nuc" requires explicit package name at make_perl_pull_genes_files.pl line 36.
Execution of make_perl_pull_genes_files.pl aborted due to compilation errors.
爲什麼你需要創建新的pl文件?如果需要,最好使用不同的命令行創建一個pl。 – TrueY 2013-04-21 16:00:53