print `dir /b $source\\*.txt > $source\\dir_list.lst`; #$source is declared just before the sub is called #### @list = glob "$source\\*.txt";