perl牛人请进

perl牛人请进

perl牛人请进
列1  列2 列3 列4
0x40 g1 g2 g3
0x00 g2 g3 g6
0x01 g1 g3 g0
如何用perl检索上一行的列4与下一行的列2或列3的字符是否一样?
大牛谢谢了!!!!!
这么难呀!.
[CCB]2[/CCB].
[quote]--#!/usr/bin/pe.

#!/usr/bin/perl -W

use strict;
use warnings;

my $str = << "__END__";
0x40 g1 g2 g3
0x00 g2 g3 g6
0x01 g1 g3 g0
__END__

my $previous_column4 = "";

my @matched_lines;

while ($str =~ /((\S+?)\s+?(\S+?)\s+?(\S+?)\s+?(\S+?)\b)/g) {

  if (($3 eq $previous_column4) and ($4 eq $previous_column4)) {

   push @matched_lines, $1;
  }

  $previous_column4 = $5;
}

print @matched_lines;