2009-05-06

ls2csv.pl

#!/usr/bin/perl -w
#
# ls2csv.pl - show a listing of the PHP file
#            (*.inc and *.php) 
#             as a CSV table; no table headings included in 
#             output; no params defined
#
sub create_listing($) 
{
  my $xtn = shift;
  my @files = `ls -ghoG *.$xtn`;
  foreach my $f (@files) {
    chomp($f);
    $f =~ s/^\s*[-rw]+\s+\d\s+(.+)/$1/;
    $f =~ s/ /\",\"/g;
    $f =~ s/^(.)/\"$1/;
    $f =~ s/(.)$/$1\"/;
    print "$f\n";
  }
}

map { create_listing($_) } ("inc","php");