Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use feature 'say';
- sub error {
- my ($x1, $y1, $d1, $x2, $y2, $d2) = @_;
- return undef if abs($x1 - $x2) > .20001 || abs($y1 - $y2) > .20001;
- return [$d1, $d2];
- }
- my $data1 = []; my $data2 = [];
- open my $d1, '<data1.dat' or die; open my $d2, '<data2.dat' or die;
- while (<$d1>) {
- next if /\Ax座標/;
- chomp; my @d = split; push @$data1, \@d;
- }
- while (<$d2>) {
- next if /\Ax座標/;
- chomp; my @d = split; push @$data2, \@d;
- }
- close $d1; close $d2;
- my $size1 = scalar @$data1; my $size2 = scalar @$data2;
- open my $out, '>output.dat' or die;
- for (my $i = 0; $i < $size1; $i++) {
- for (my $j = 0; $j < $size2; $j++) {
- my @d = (
- $data1->[$i][0], $data1->[$i][1], $data1->[$i][2],
- $data2->[$j][0], $data2->[$j][1], $data2->[$j][2]
- );
- my $error = error @d;
- next unless defined $error;
- say $out join "\t", @$error;
- }
- }
- close $out;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement