Well, I'll give this problem a go even though it has been beaten to death already. It's a bit long, but it works all the same.
use strict;
my %files;
my @files;
@files =<DATA>;
@files = map { s/\n//; $_ } @files;
close(DATA);
foreach (@files) {
$files{substr($_,0,(length()-4))}++;
}
foreach (keys %files) {
print "$_ is not matched and has a count of $files{$_}\n" if $file
+s{$_} == 1;
}
__DATA__
001.did
001.mrg
002.did
002.mrg
003.did
004.did
005.did
005.mrg
The output of this is:
C:\configs>perl test.pl
003 is not matched and has a count of 1
004 is not matched and has a count of 1
Of course, this code is nothing more than a modified "seen" loop. Not too fancy. One thing I should point out is that if you use
foreach (<*.mrg>), it'll do the same thing as your glob (because it is the same thing as far as I know). It's just shorter. Hope that sparks a few ideas.
Theodore Charles III
Network Administrator
Los Angeles Senior High
email->secon_kun@hotmail.com
perl -e "map{print++$_}split//,Mdbnr;"
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.