use strict; use File::Find; my $cod = shift or die 'some error message'; my $dbpath = '/path/to/somewhere'; my @files; @ARGV = '.' unless @ARGV; find sub { push(@files, $_) if /\.mp3\z/; }, @ARGV; open(DB, ">$dbpath/$cod.txt") || die $!; print DB map { s/\.mp3\z/\n/; $_ } sort @files; #### use strict; use File::Find; my $cod = shift or die 'some error message'; my $dbpath = '/path/to/somewhere'; @ARGV = '.' unless @ARGV; my @files = get_files(@ARGV); open(DB, ">$dbpath/$cod.txt") || die $!; print DB trim(@files); sub get_files { my @file; find sub { push(@file, $_) if /\.mp3\z/; }, @_; return @file; } sub trim { return map { s/\.mp3\z/\n/; $_ } sort @_; }