我有两个矩阵(例如A和B)。我想基于A的第一列的顺序来提取B的列: 例如 矩阵A name score
a 0.1
b 0.2
c 0.1
d 0.6
矩阵B a d b c g h
0.1 0.2 0.3 0.4 0.6 0.2
0.2 0.1 0.4 0.7 0.1 0.1
...
我想矩阵B到看起来像这样最后 matrix B_modified a b c d
0.1
我有一个关于在Perl中通过引用子例程的问题。对于如果我通过使用@_的值,它可以工作,但仅供参考移位工作。不知道为什么。下面我已经givedn示例代码: 这工作: #! /usr/bin/perl
use strict;
use warnings;
my $name = 'John';
PassScalarByRef(\$name);
sub PassScalarByRef{
我是Perl新手,尝试理清问题但没有成功。我正在尝试从文本文件中读取数据。该代码是: open FH, 'D:\Learning\Test.txt' or die $!;
my @data_line;
while (<FH>)
{
@data_line = split (/\|\~/);
print @data_line;
}
文件内容是这样的: 101|~John|~This l
看到脚本(见下文),但无法找到更多关于“-n”的信息。 my $numeric =0;
my $input = shift;
if ($input eq "-n") {
$numeric =1;
$input = shift;
}
my $output = shift;
open INPUT, $input or die $!;
open OUTPUT, ">$ou