If you use File::Basename, you can skip all that prep work and analyze your data directly.

#!/usr/bin/perl use warnings; use strict; use File::Basename; ### code from here ### 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" ); print "\n"; print "-" x 80, "\n"; print "-- REPEATED SOURCE(S):\n"; print "-" x 80, "\n"; my $fileidx = 0; my $hit = 0; my $hitcntr = 0; my $last_source = $#classedSources; foreach (sort { basename($a) cmp basename($b) } @classedSources ) { $fileidx++; next if $fileidx > $last_source; my ($file, $path) = fileparse( $_ ); my ($nextFile, $nextPath) = fileparse( $classedSources[$fileidx] ); if ($file eq $nextFile) { $hit = 1; $hitcntr++; print "\n$file\n" if $hitcntr == 1; print " " x 6, $path."\n"; } else { print " " x 6, $path."\n" if $hit; $hit = 0; $hitcntr = 0; } }

In reply to Re: sorting a filelist array by filename by dwm042
in thread sorting a filelist array by filename by Vasek

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.