perl_learner wrote:
Hi,
I have these type of kits in unix location.
aaa.t.z aaa_d.t.z bbb.t.z bbb_d.t.z ccc.t.z ccc_d.t.z ddd.t.z eee.t.z
(there will be more numbers).
I have to come up with idea, so that ,
it compares for each *.t.z kit in that location, that it has the
corresponding *_d.t.z. If any *.t.z doesn't have corresponding
*_d.t.z, it will print out the list of that/those kit/kits. In this
case, it should print out:
ddd.t.z eee.t.z
Currently I am putting the kit list in an array, still not able to
compare them correctly.
One way:
my @kits = qw( aaa.t.z aaa_d.t.z bbb.t.z bbb_d.t.z
ccc.t.z ccc_d.t.z ddd.t.z eee.t.z );
my %hash = map {
( my $tmp = $_) =~ s/_d(\.t\.z)$/$1/; $tmp => 1
} grep /_d\.t\.z$/, @kits;
foreach my $kit ( grep !/_d\.t\.z$/, @kits ) {
print "$kit\n" unless $hash{$kit};
}
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/