#!/usr/bin/perl use warnings; use strict; use JSON; use Cwd 'abs_path'; use lib abs_path("../../")."/sibelius2/conf"; use Paths; #------------------------- print getNames( Paths::MOD ."/cal/img"); sub getNames{ my $dir = shift; my @file_name; opendir(DIR, $dir) or die "error opening dir: $dir \n$!"; while (my $file = readdir(DIR)) { next unless ( $file =~m/^[\w\d]/); next unless (-f "$dir/$file"); push(@file_name,{name=>$file,tag=>"ilist"}); } closedir(DIR); return encode_json( \@file_name ); } 1; __END__