没有提取数据输出到data2.txt?代码出了什么问题?
MyFile.txt的
ex1,fx2,xx1
mm1,nn2,gg3
EX1,hh2,ff7
Run Code Online (Sandbox Code Playgroud)
这是data2.txt中我想要的输出:
ex1,fx2,xx1
EX1,hh2,ff7
Run Code Online (Sandbox Code Playgroud)
#! /DATA/PLUG/pvelasco/Softwares/PERLINUX/bin/perl -w
my $infile ='My1.txt';
my $outfile ='data2.txt';
open IN, '<', $infile or die "Cant open $infile:$!";
open OUT, '>', $outfile or die "Cant open $outfile:$!";
while (<IN>) {
if (m/EX$HF|ex$HF/) {
print OUT $_, "\n";
print $_;
}
}
close IN;
close OUT;
Run Code Online (Sandbox Code Playgroud) 我正在从这样的文件中读取数据
while (<$fh>)
{
@tmp = split; # <-- ?
push @AoA, [@tmp];
}
Run Code Online (Sandbox Code Playgroud)
我有几个问题.标记线有什么作用?它是否按行分割文件并将每行的元素存储到数组中?如果是这样,是否可以将@tmp转换为字符串或在@tmp上执行正则表达式?
基本上我想停止将数据推送到AoA上,如果我在文件中找到除空格或整数之外的任何内容.我已经有了正则表达式:\ ^ [\ s\d]*$ \
我正在尝试编写一个调用另一个脚本的Perl脚本,该脚本读取整个目录.我没有得到任何错误,但我也没有得到预期的结果.屏幕上没有任何内容.
我不需要在屏幕上输出任何内容.我在exec()
语句中调用的脚本应该将每个图像文件读入DIR
目录,并创建一个文件,用于存储从该图像中提取的一些数据.exec()
然后循环语句中的脚本,直到读取到目录中的所有图像.
#!/usr/bin/perl -w
use strict;
use warnings;
use diagnostics;
use CGI qw/:standard/;
use CGI::Carp 'fatalsToBrowser';
my $dir = '/FilesToRead/';
my $fichier;
my $ligne;
my $mimetype;
my @listeFichiers;
my $cgi = CGI -> new();
opendir (DIR, $dir) or die "Impossible d'ouvrir $dir: $!";
@listeFichiers = grep {/\.mem$/ && -f "$dir/$_"} readdir (DIR);
while (my $ouvRep = readdir(DIR))
{
foreach $fichier (@listeFichiers)
{
exec "v-file ./param.par ./Picture/$fichier -PM_overflow 3000000" or die "Script perl ne s'est …
Run Code Online (Sandbox Code Playgroud) 我已经考虑CGI::Application
和CGI::Session
.在这两者中,CGI::Session
似乎更有希望.CGI::Application
然而,模型看起来并不适用于使用Template Toolkit.(这样做我错了吗?)
我想在评估之前评估更多的会话管理库.有什么建议?我正在寻找一个与Web服务器无关的库,并且可以在多个服务器上运行.由于将现有代码改造为Catalyst处理方式所需的时间,Catalyst现在不是一个选项.
我可以有这样的构造函数:
sub create {
my $class = shift;
my $self = {};
return bless $self,$class;
}
Run Code Online (Sandbox Code Playgroud)
当我创建一个对象时,我可以这样写:
my $object = create Object;
Run Code Online (Sandbox Code Playgroud)
这是:
my $object = Object::create("Object");
Run Code Online (Sandbox Code Playgroud)
唯一相当于那个构造函数的调用?
假设我有一些原始文本:
here is some text that has a substring that I'm interested in embedded in it.
我需要文本匹配它的一部分,说:" has a substring
".
但是,原始文本和匹配字符串可能存在空格差异.例如,匹配文本可能是:
has a substring
要么
has a substring
和/或原始文本可能是:
here is some text that has a substring that I'm interested in embedded in it.
我需要我的程序输出的是:
here is some text that [match starts here]has a substring[match ends here] that I'm interested in embedded in it.
我还需要保留原始的空白模式,只需添加开始和结束标记即可.
关于使用Perl正则表达式来实现这一点的任何想法?我试过了,但最终变得非常困惑.
如何使用替换矩阵修改Smith-Waterman算法来对齐Perl中的蛋白质?
[引用需要]
我正在尝试使用perl从网络服务/ API获取数据,例如Delicious API.有谁知道如何使用本机API(不是来自CPAN的模块)从网络服务/ API获取此类XML格式数据?
我有一个文件,包括以下内容:
A 1 A 2 B 3 B 4 B 5 B 6 C 7 A 8
我想在第一列中获取所有唯一键,但获取该唯一键的所有相应值,即我需要获取:
A 1,2,8 B 3,4,5,6 C 7
最好的方法是什么?
(我听说Perl有很好的支持来解决这个问题,但我是Perl的新手.)
我试图将整个网页保存在我的系统上作为.HTML文件,然后解析该文件,找到一些标签并使用它们.我能够保存/解析http:/ url,但无法保存/解析https:/ url.我正在使用Perl.我使用以下代码来保存http,它工作正常.但不适用于https.是否可以解析https页面?? ..:
use strict;
use warnings;
use LWP::Simple qw($ua get);
use LWP::UserAgent;
use LWP::Protocol::https;
use HTTP::Cookies;
sub main
{
my $ua = LWP::UserAgent->new();
my $cookies = HTTP::Cookies->new(
file => "cookies.txt",
autosave => 1,
);
$ua->cookie_jar($cookies);
$ua->agent("Google Chrome/30");
#$ua->ssl_opts( SSL_ca_file => 'cert.pfx' );
$ua->proxy('http','http://proxy.com');
my $response = $ua->get('http://google.com');
#$ua->credentials($response, "", "usrname", "password");
unless($response->is_success) {
print "Error: " . $response->status_line;
}
# Let's save the output.
my $save = "save.html";
unless(open SAVE, '>' . $save) {
die "nCannot create save …
Run Code Online (Sandbox Code Playgroud) perl ×10
arrays ×2
regex ×2
algorithm ×1
bioperl ×1
dna-sequence ×1
duplicates ×1
exec ×1
extract ×1
html ×1
https ×1
math ×1
networking ×1
oop ×1
string ×1
substitution ×1
text ×1