my @txt = glob(*.txt); my @sql = map {$a=$_;$a=~s~\.txt$~.sql~;$a} @txt;