## early on.. $filepath = '/dir/of/file/'; ## in your foreach/while for your file push(@files,$field6); ## later on... $d = join("','", @files); $d = "'" . $d . "'"; #### $file1 = '/dir/of/file/filename1.txt'; $file2 = '/dir/of/file/filename2.txt'; ## then send both variables to the module: $file1,$file2