Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

•Re: Re: Finding un-paired files in a directory

by merlyn (Sage)
on Dec 02, 2003 at 12:16 UTC ( [id://311591]=note: print w/replies, xml ) Need Help??


in reply to Re: Finding un-paired files in a directory
in thread Finding un-paired files in a directory

use strict; use Data::Dumper; chomp(my @files = <DATA>); # find unique basenames my @basenames = keys %{{ map { (split/\./)[0] => 1 } @files }}; # find unpaired files foreach my $basename (@basenames) { my @matches = grep (/$basename/, @files); print "$matches[0]\n" if $#matches == 0; }
No, this solution breaks if any filenames have regex-significant metachars, or are partially within a larger filename.

In my opinion, the original solution is actually the most direct, as this is a classic set difference problem.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://311591]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-23 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found