http://www.perlmonks.org?node_id=795721

fiddler42 has asked for the wisdom of the Perl Monks concerning the following question:

Kind Folk,

I have a list of c. 5,000 files that I need to collapse into the smallest possible list of files with wildcards. For example, say I have some files named:-

abcpwbln08 abcpwbln07 abcpwbnn10 abcpwbnn06 adesicln09 adesicln08 adesicln01 adesicnn05
...and I need to reduce them to:-

abcpwbln0* abcpwbnn* adesicln0* adesicnn05
Any suggestions on how to do this as efficiently as possible in perl? The routine will start off by just reading in the contents of a user-specified unix directory. The names will be very similar to what's referenced above.

Thanks,

-fiddler42