Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Perl >> Snippet

List of all files then separate file from path


#!/usr/bin/perl -w
use strict;

my @all_files = `dir \\ *.* /s/b`;
my %filecounts ;
foreach my $file_and_path ( @all_files ) {
   $file_and_path = ~ m /(.*)\\(.*)$/; # (Windows only)
   my ( $path , $name ) = ( $1 , $2 );
   $filecounts { $name } ++ ;
}

foreach my $this_file ( sort keys %filecounts ) {
print "$this_file: $filecounts{$this_file} \n " ;
}