- 论坛徽章:
- 0
|
本帖最后由 华小飞_Perl 于 2016-08-07 21:27 编辑
写了个Perl代码发到shell的版块,不会被说吧- #!/usr/bin/perl
- use warnings;
- use strict;
- open INPUT_1, '<', 'b.txt' or die "Don't open the file: $!";
- open INPUT_2, '<', 'a.txt' or die "Don't open the file: $!";
- my (@b_array, %b_hash);
- while (<INPUT_1>) {
- chomp;
- push @b_array, $_;
- }
- %b_hash = map { $_ => 1 } @b_array;
- my $ref_b = \%b_hash;
- while (my $a_item = <INPUT_2>) {
- chomp $a_item;
- my $copy_of_a = $a_item;
- $a_item =~ s/(\w{7})\w+/$1/;
-
- print $copy_of_a, "\n" if ( $ref_b->{$a_item} );
- }
- close INPUT_1;
- close INPUT_2;
复制代码 |
|