%a = ( "KEY" => {
"p1" => 1 , [1223],
"p1" => 2 , [2323],
"p1" => 3 , [2353],
}
);
Run Code Online (Sandbox Code Playgroud)
我想生成这样的结构.我尝试过这段代码:
@array = ( 1223 , 2323 ,2353 );
$count = 0;
foreach my $i (@array) {
$a{"KEY"} => { "p1" => $count , [$i] };
$count++;
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能创建这样的哈希?
如何在Perl表单网站URL中找到图像文件类型?
例如,
$image_name = "logo";
$image_path = "http://stackoverflow.com/content/img/so/".$image_name
Run Code Online (Sandbox Code Playgroud)
从这个信息中如何找到那个文件类型.这里应该显示的例子
"png"
http://stackoverflow.com/content/img/so/logo.png .
Run Code Online (Sandbox Code Playgroud)
如果它有更多的文件,如SO网站,则提供支持.它应该显示所有文件类型
例如:
open (PS , " tail -n 1 $file | grep win " );
Run Code Online (Sandbox Code Playgroud)
我想查找文件句柄是否为空.
$aa = "Main:http://google-test.com:8080/service"
(or)
$aa = "http://google-test.com:8080/service2"
Run Code Online (Sandbox Code Playgroud)
我想把它分成两部分:
Main:
http://google-test.com:8080/service
Run Code Online (Sandbox Code Playgroud)
但它不适用于这种分裂:
split (/\:/,$aa,1);
Run Code Online (Sandbox Code Playgroud) use LWP::Simple;
use Parallel::ForkManager;
@links=(
["http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-windows.exe","SweetHome3D-2.1-windows.exe"],
["http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-macosx.dmg","SweetHome3D-2.1-macosx.dmg"],
["http://prdownloads.sourceforge.net/sweethome3d/SweetHome3DViewer-2.1.zip","SweetHome3DViewer-2.1.zip"],
);
# Max 30 processes for parallel download
my $pm = new Parallel::ForkManager(30);
foreach my $linkarray (@links) {
my $pid = $pm->start and next; # do the fork
my ($link,$fn) = @$linkarray;
warn "Cannot get $fn from $link"
if getstore($link,$fn) != RC_OK;
print "$pid = $link is done ";
$pm->finish; # do the exit in the child process
}
$pm->wait_all_children;
Run Code Online (Sandbox Code Playgroud)
执行完毕后,我要去pid是零
0 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3DViewer-2.1.zip is done 0 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-macosx.dmg is done 0 …
数据库数据:
Passport_No Bank statement_no Credit_id
4126897 HSBC 2948608 0
4126897 HSBC 2948609 1
4126858 HSBC 2948591 0
4126858 barclays 2948595 0
4126858 barclays 2948596 1
4126858 barclays 2948597 2
Run Code Online (Sandbox Code Playgroud)
信用ID基于银行.
Credit_id(我需要填写)0,1,2,3,4
我试图像这样自动化
if ($credit{$passport_no}{$bank}) {
$credit{$passport_no}{$bank}->{$statement}++;
} else {
$credit{$passport_no}{$bank}->{$statement} = 0;
}
Run Code Online (Sandbox Code Playgroud)
我得到了外面的东西:
VAR1 = '4126897';
$VAR2 = {
'HSBC' => {
'2948608' => 0,
'2948609' => '1'
}
};
$VAR3 = '4126858';
$VAR4 = {
'HSBC' => {
'2948591' => 0
},
'barclays' => {
'2948595' => 0, …Run Code Online (Sandbox Code Playgroud) 我正在从外部程序捕获一些输出:
my $cmd = "grep -h $text $file2 $file1 | tail -1 | awk '{print \$NF }' ";
my $port_number;
$port_number =`$cmd`;
print "port No : ==$port_number==";
Run Code Online (Sandbox Code Playgroud)
输出在端口号周围有额外的空格:
port No : == 2323
==
Run Code Online (Sandbox Code Playgroud)
我试过chomp但它不起作用。
我想将多个XML文件合并到Perl中的单个XML文件中.
档案1:
<r1>
<searchpath>
<dir>/usr/bin</dir>
<dir>/usr/local/bin</dir>
<dir>/usr/X11/bin</dir>
</searchpath>
</r1>
Run Code Online (Sandbox Code Playgroud)
文件2:
<r2>
<user login="grep" fullname="Gary R Epstein" />
<user login="stty" fullname="Simon T Tyson" />
</r2>
Run Code Online (Sandbox Code Playgroud)
合并文件
<XML>
<r1>
<searchpath>
<dir>/usr/bin</dir>
<dir>/usr/local/bin</dir>
<dir>/usr/X11/bin</dir>
</searchpath>
</r1>
<r2>
<user login="grep" fullname="Gary R Epstein" />
<user login="stty" fullname="Simon T Tyson" />
</r2>
</XML>
Run Code Online (Sandbox Code Playgroud) 我想将分裂整数分解为它们的因素.例如,如果记录总数为:
169 - ( 13 x 13 times)
146 - ( 73 x 2 times)
150 - ( 50 x 3 times)
175 - ( 25 x 7 times)
168 - ( 84 x 2 )
160 - ( 80 x 2 times)
Run Code Online (Sandbox Code Playgroud)
当它超过10k时 - 我想要1000上的所有东西当它超过10万时 - 我希望一切都在10k上
通过这种方式,我想要计算数字.怎么做到这一点?是否有任何Perl模块可用于这些类型的操作?
假设记录总数为10k.它应该分开1000x10倍; 不是100或10.
我可以使用sqrt功能.但这并不总是我所期待的.如果我给出输入146,我必须得到(73,2).