On May 5, 3:26=A0am, nore...@[EMAIL PROTECTED]
(Gunnar Hjalmarsson) wrote:
> 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:
>
> =A0 =A0 =A0my @[EMAIL PROTECTED]
=3D qw( aaa.t.z aaa_d.t.z bbb.t.z bbb_d.t.z
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ccc.t.z ccc_d.t.z ddd.t.z eee.t.z
)=
;
>
> =A0 =A0 =A0my %hash =3D map {
> =A0 =A0 =A0 =A0 =A0( my $tmp =3D $_) =3D~ s/_d(\.t\.z)$/$1/; $tmp =3D> 1
> =A0 =A0 =A0} grep /_d\.t\.z$/, @[EMAIL PROTECTED]
>
> =A0 =A0 =A0foreach my $kit ( grep !/_d\.t\.z$/, @[EMAIL PROTECTED]
) {
> =A0 =A0 =A0 =A0 =A0print "$kit\n" unless $hash{$kit};
> =A0 =A0 =A0}
>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl-
Hide quoted text -
>
> - Show quoted text -
Hi Gunner,
Thanks for your reply. It works out if I use qw option. However I have
bigger list. I am sending my program, it provides me both *_d.t.Z as
well as *Z list. Not doing the comparison. Can you have a look again?
So looks like the comparison is not working.
Thanks in advance.
$KIT_LOCATION=3D"/lnx/dep/packages";
$KIT_LIST=3D`ls $KIT_LOCATION/*.t.Z`;
#print $KIT_LIST;
$KIT_LIST=3D~ s/$KIT_LOCATION\///g;
#print $KIT_LIST;
my @[EMAIL PROTECTED]
=3D $KIT_LIST;
chomp ($kits);
#print "@[EMAIL PROTECTED]
";###prints out both .Z and _d.t.Z
my %hash =3D map {
( my $tmp =3D $_) =3D~ s/_d(\.t\.Z)$/$1/; $tmp =3D> 1
} grep /_d\.t\.Z$/, @[EMAIL PROTECTED]
#print "@[EMAIL PROTECTED]
"; #prints out both .Z and _d.t.Z
foreach my $kit ( grep !/_d\.t\.Z$/, @[EMAIL PROTECTED]
) {
#print "$kit\n" unless $hash{$kit}; #prints out both .Z and
_d.t.Z
}


|