#!/usr/local/bin/perl

if ($#ARGV >= 0) {
  $cmd = "ls " . $ARGV[0] . " |";
}
else {
  $cmd = "ls |";
}

open( READ, $cmd ) || die "couldn't open $cmd: $!\n"; 

while( <READ> ) {
  chomp;
  push @files, $_;
}

$name = "list.txt";
open( FILE, ">$name" );

for( $i = 0; $i < $#files; $i++ ) 
{

  $img = $files[$i];
  $img =~ m/([^\/]*)\.([^.]*)$/;

  print FILE <<EOF;
img[] = '$img';
EOF
}

close( FILE );
close( READ );

