Assuming that you only want to delete those rows with "wildcards" that cannot match any other row (with or without wildcards) you cannot just simply delete all rows that contain a "9".

To check this assumption I have added an extra row of data "2 2 9 2 2". That row cannot match any of the other rows and therefore should not be deleted.

use Modern::Perl qw/2015/; my %data; # First we transform and load the data into a hash while (<DATA>) { chomp; my $data = $_; s/([^9 ])/[$1X]/g; s/9/[0129]/g; s/X/9/g; $data{$_} = $data; } #Then we check if records with missing data are unique for my $testrecord ( keys %data ) { next unless $data{$testrecord} =~ m/9/; for my $record ( keys %data ) { next if $data{$record} eq $data{$testrecord}; #don't check you +rself if ( $data{$record} =~ m/$testrecord/ ) { delete $data{$testrecord}; last; } } } say $data{$_} for keys %data; __DATA__ 2 2 0 1 0 2 2 0 2 1 0 2 1 1 0 0 1 1 1 0 2 2 0 0 0 2 9 0 2 1 0 2 0 1 0 2 2 0 9 0 2 2 9 2 2
Output:
0 1 1 1 0 0 2 0 1 0 2 2 0 1 0 2 2 0 0 0 2 2 0 2 1 0 2 1 1 0 2 2 9 2 2

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

In reply to Re: Imputation of data by CountZero
in thread Imputation of data by garyboyd

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.