Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > Re: comparing k...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 11 Topic 11027 of 11531
Post > Topic >>

Re: comparing kit names

by noreply@[EMAIL PROTECTED] (Gunnar Hjalmarsson) May 5, 2008 at 12:26 PM

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 @[EMAIL PROTECTED]
 = 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$/, @[EMAIL PROTECTED]
     foreach my $kit ( grep !/_d\.t\.z$/, @[EMAIL PROTECTED]
 ) {
         print "$kit\n" unless $hash{$kit};
     }

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 




 11 Posts in Topic:
comparing kit names
rahman77@[EMAIL PROTECTED  2008-05-05 01:10:52 
Re: comparing kit names
noreply@[EMAIL PROTECTED]  2008-05-05 12:26:04 
Re: comparing kit names
rahman77@[EMAIL PROTECTED  2008-05-05 16:34:43 
Re: comparing kit names
noreply@[EMAIL PROTECTED]  2008-05-06 19:08:14 
Re: comparing kit names
rahman77@[EMAIL PROTECTED  2008-05-06 22:07:06 
Re: comparing kit names
noreply@[EMAIL PROTECTED]  2008-05-07 13:55:08 
Re: comparing kit names
krahnj@[EMAIL PROTECTED]   2008-05-07 09:01:54 
Re: comparing kit names
noreply@[EMAIL PROTECTED]  2008-05-07 22:08:39 
Re: comparing kit names
rahman77@[EMAIL PROTECTED  2008-05-07 08:30:23 
Re: comparing kit names
noreply@[EMAIL PROTECTED]  2008-05-08 18:09:45 
Re: comparing kit names
rahman77@[EMAIL PROTECTED  2008-05-09 10:48:29 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 19:12:55 CDT 2008.