我是php,mysql的新手.我写了一个hello.php脚本,我试图将其复制到/ var/www目录中(稍后将要通过Web浏览器打开它).同样的问题是,尽管我是root用户,但我不允许在/ var/www中保存/写入任何文件.我尝试在这个问题中实现步骤,但是当我处理第三行时出现以下错误
find /var/www/ -type f -exec chmod g+w '{}' ';'
chmod: changing permissions of `/var/www/index.html': Operation not permitted
Run Code Online (Sandbox Code Playgroud)
我知道符号链接也是一种选择.我希望能够直接将文件写入/复制到/ var/www /目录.
什么是错误的任何建议?
以下脚本用于在蛋白质序列中找到一个基序.
use strict;
use warnings;
my @file_data=();
my $protein_seq='';
my $h= '[VLIM]';
my $s= '[AG]';
my $x= '[ARNDCEQGHILKMFPSTWYV]';
my $regexp = "($h){4}D($x){4}D"; #motif to be searched is hhhhDxxxxD
my @locations=();
@file_data= get_file_data("seq.txt");
$protein_seq= extract_sequence(@file_data);
#searching for a motif hhhhDxxxxD in each protein sequence in the give file
foreach my $line(@file_data){
if ($motif=~ /$regexp/){
print "found motif \n\n";
} else {
print "not found \n\n";
}
}
#recording the location/position of motif to be outputed
@locations= match_position($regexp,$seq);
if (@locations){
print "Searching …Run Code Online (Sandbox Code Playgroud) 我有以下脚本,它接收输入文件,输出文件并用其他字符串替换输入文件中的字符串并写出输出文件.
我想更改脚本遍历文件目录,即不是提示输入和输出文件,脚本应该将目录路径作为参数,例如C:\ temp\allFilesTobeReplaced \并搜索字符串x并替换它使用y表示该目录路径下的所有文件并写出相同的文件.
我该怎么做呢?
谢谢.
$file=$ARGV[0];
open(INFO,$file);
@lines=<INFO>;
print @lines;
open(INFO,">c:/filelist.txt");
foreach $file (@lines){
#print "$file\n";
print INFO "$file";
}
#print "Input file name: ";
#chomp($infilename = <STDIN>);
if ($ARGV[0]){
$file= $ARGV[0]
}
print "Output file name: ";
chomp($outfilename = <STDIN>);
print "Search string: ";
chomp($search = <STDIN>);
print "Replacement string: ";
chomp($replace = <STDIN>);
open(INFO,$file);
@lines=<INFO>;
open(OUT,">$outfilename") || die "cannot create $outfilename: $!";
foreach $file (@lines){
# read a line from file IN into $_
s/$search/$replace/g; # change …Run Code Online (Sandbox Code Playgroud) 我在阅读脚本时遇到了这种语法.我不确定方括号的用途是什么.
push @data, [ split //, $line ]; #printing this array gives crap values
Run Code Online (Sandbox Code Playgroud)
或者换句话说,上面和下面的区别是什么?
push @data, (split//, $line); #printing this gives actual values
Run Code Online (Sandbox Code Playgroud)
有什么建议?
我正在我的个人计算机上编写一个脚本,该脚本连接到远程服务器.我认为远程服务器安装了Perl 4.0或更低版本,这就是它无法识别相同的原因.有chomp命令的替代方案吗?
以下是我正在处理的数据:
__DATA__
Node 1:
98 debug : fill 100
102 debug : fill 104
Node 2:
88 debug : fill 120
152 debug : fill 164
Run Code Online (Sandbox Code Playgroud)
我想写一个正则表达式/(或任何合适的)从节点1下面的数据中捕获信息,比如'98:100',但只有在识别出节点1并将其存储在一个数组中后才说@ value1(即@ value1中的值)对应于节点1)下面的数据.并且类似地从节点2下面的数据捕获和存储信息,比如152:164,在已经在不同的阵列中识别节点2之后说'@ value2'.我用来捕获信息的正则表达式是" qr/\s+([0-9]{2,3})\s[a-z]+\s(:)\s[a-z]\s([0-9]{3})/".但是,如果我使用'if'语句
while (<>){
if ($_=~ /Node 1/){
#capture information using regex
}
}
Run Code Online (Sandbox Code Playgroud)
在正则表达式之前,脚本不会返回任何值,可能是因为它在单词"Node"之后的同一行中搜索或正则表达式.
有关如何在识别特定节点后跳转到下一行并使用正则表达式捕获信息的任何建议.
我想在文件的顶部和底部添加一行.我可以按照以下方式做到.
open (DATA, "</usr/old") || die "cant open old\n"; #file to which line has to be added
my @body=<DATA>;
close(DATA);
open (FILE, ">/usr/new") || die "cant open new\n"; #file after stuff has been added
print FILE "9 431";
print FILE "\n";
my $body=@body;
for (my $i=0; $i<$body;$i++){
print FILE "$body[$i]";#not using for loop leads to addition of spaces in new file
}
print FILE "(3,((((1,4),(7,6)),(2,8)),5),9)";
Run Code Online (Sandbox Code Playgroud)
由于我运行大量文件,因此这个过程非常耗时.Perl是否具有用于在文件顶部和底部添加行的任何特定功能?
我编写了一个Perl脚本,它打开一个由各种文件组成的目录.似乎脚本不按任何顺序读取文件(既不按字母顺序也不按字母顺序),而是随机读取它们.我想知道背后的原因是什么?
我在Perl中搜索一个字符串并将其存储在另一个标量变量中.我想打印这个标量变量.下面的代码似乎不起作用.我不确定出了什么问题,以及正确的方法是什么.为什么在程序中不存在时打印"1"?
正在运行的数据
数据
13 E 0.496 -> Q 0.724
18 S 0.507 -> R 0.513
19 N 0.485 -> S 0.681
21 N 0.557 -> K 0.482
Run Code Online (Sandbox Code Playgroud)
以下是我的代码:
#!/usr/bin/perl
use strict;
use warnings;
my $find = '\s{10}[0-9]{2}\s[A-Z]'; #regex. it can also be '\s{10}[0-9]{2}\s[A-Z]'
#both dont seem to work
my @element;
open (FILE, "/user/run/test") || die "can't open file \n";
while (my $line = <FILE>) {
chomp ($line);
print "reached here1 \n"; # to test whether it reading the program properly …Run Code Online (Sandbox Code Playgroud) 我需要将哈希值插入数据库.以下是我必须在table1列键和值中插入值的代码模板:
use DBI;
use strict;
%hash; #assuming it already contains desired values
my $dbh = DBI->connect(
"dbi:Sybase:server=$Srv;database=$Db",
"$user", "$passwd"
) or die sprintf 'could not connect to database %s', DBI->errstr;
my $query= "Insert INTO table1(key, values) VALUES (?,?) ";
my $sth = $dbh->prepare($query)
or die "could not prepare statement\n", $dbh->errstr;
$sth-> execute or die "could not execute", $sth->errstr;
Run Code Online (Sandbox Code Playgroud)
我知道如何使用数组插入值,即使用execute_array(),但不知道如何插入%hashtable1中存在的值.
有什么建议?