- 论坛徽章:
- 0
|
中规中矩的写一个:
- #!/usr/bin/perl
- use warnings;
- use strict;
- open FILE_1, '<', 'lst1.txt' or die "Error 1 occured: $!";
- open FILE_2, '<', 'lst2.txt' or die "Error 2 occured: $!";
- my (@sample, @index, $sample, $index);
- while (<FILE_1>) {
- chomp;
- if (/^(\w+),(\w+)/m) {
- $sample = $1.",".$2;
- push @sample, $sample;
- }
- }
- while (<FILE_2>) {
- chomp;
- my @med = split;
- $index = join ",", @med;
- push @index, $index;
- }
- while (@sample) {
- my $sig_smp = shift @sample;
- my $sig_index = shift @index;
- my $combine = $sig_smp.",".$sig_index;
- print $combine, "\n";
- }
复制代码 |
|