in reply to sorting a filelist array by filename

How about this?
#!/usr/bin/perl use strict; my @classedSources = ( "hitdb/CustomerPartner/Opten/Scripts/Daily/egy_batch.sql", "hitdb/CustomerPartner/Opten/Scripts/Daily/megegy_batch.sql", "hitdb/CustomerPartner/Opten/Scripts/Other/cp_OptenTruncTables.sql", "hitdb/CustomerPartner/Opten/Scripts/Other/htcp_firm_loadAll.sql", "hitdb/CustomerPartner/Opten/Scripts/Other/runHT_CP_EKN.sql", "hitdb/CustomerPartner/Opten/Scripts/Other/runHT_CP_FIRM.sql", "hitdb/Policy/Views/Types/HtTypoWsAlaTarifFE1.sql", "hitdb/Policy/Types/HtTypoWsHobMfactorFE1.sql", "hitdb/Policy/Types/HtTypoWsCoverAlaFE1.sql", "hitdb/Policy/Views/Types/HtTypoWsCoverAlaFE1.sql", "hitdb/Policy/Types/HtTypoWsCoverAlaListFE1.sql", "hitdb/Policy/Views/Types/HtTypoWsCoverAlaListFE1.sql", "hitdb/Security/Scripts/ht_tut_mail_address_ws.sql", "hitdb/Policy/Views/Types/HtTypoWsHobMfactorFE1.sql", "hitdb/Accounting/Scripts/ht_tut_mail_address_ws.sql", "hitdb/Policy/Scripts/ht_tut_mail_address_ws.sql", "hitdb/Policy/Types/HtTypoWsAlaTarifFE1.sql", "hitdb/astools/as#arch/Setup/Scripts/ht_tut_mail_address_ws.sql" ); my %hash; for (@classedSources) { $hash{ (split /\//)[-1] }++; } while ( my ($key, $val) = each %hash ) { if ( $val > 1 ) { my @files = grep /\b$key\b/, @classedSources; print "$key\n"; print join "\n", @files , "\n"; } }