sub fill_list { my ($mask, $file) = @_; # somewhat more efficient than two shifts open (LIST, '>', $file) or die "Couldn't open $file: $!"; for (glob($mask)){ print LIST "$_\n"; } close LIST; }