0
任何人都可以在下面的perl程序中向我解釋此打印語句。perl打印語句
#! /usr/bin/perl
use strict;
my %hash;
&Parse('first.txt');
&Parse('second.txt');
my $outputpath = 'output.txt';
unlink ($outputpath);
open (OUTPUT, ">>$outputpath") || die "Failed to open OUTPUT ($outputpath) - $!";
print OUTPUT "$_ \t" . join("\t", @{$hash{$_}}) . "\n" foreach (sort keys %hash);
close (OUTPUT) || die "Failed to close OUTPUT ($outputpath) - $!";
sub Parse {
my $inputpath = shift;
open (INPUT, "<$inputpath") || die "Failed to open INPUT ($inputpath) - $!";
while (<INPUT>) {
chomp;
my @row = split(/\t/, $_);
my $col1 = $row[0];
shift @row;
push(@{$hash{$col1}}, @row);
}
close (INPUT) || die "Failed to close INPUT ($inputpath) - $!";
return 1;
}
這是語句:
print OUTPUT "$_ \t" . join("\t", @{$hash{$_}}) . "\n" foreach (sort keys %hash);
將打印通過鍵排序的哈希值,由製表符的文件輸出分隔,每行開頭的鍵值名 – knittl 2010-07-23 10:51:04
你們是不是要學習編程語言一次完整的程序?你爲什麼不閱讀文檔來組裝你的基本詞彙? – Svante 2010-07-23 12:56:02
這是功課嗎? – Ether 2010-07-23 16:23:25