#!/usr/bin/perl #makes a list of all the maps in a counter-strike/half life map directory #and prints them to a text file #useful for making quick mapcycle files #by maxwell kruger #email me at mckruger@mcdonogh.org #type in the dir of the maps $dir = "REPLACE WITH DIRECTORY"; #type filename and dir #example: c:\sierra\countermaps.txt $mapfile = "REPLACE WITH MAP LIST FILE AND DIR"; opendir(DIR, "$dir") or die "couldnt open $dir";#open map directory if(-f $mapfile){print "The file $mapfile exists, overwrite?(y,n)\n\a";#if there is already a file &overwrite;#ask if you want to overwrite } else{&makefile} sub overwrite { $question = ;#user input chomp $question; #cuts off white space at end of $question if($question eq 'y'){&makefile;} #if user wants to overwrite, overwrite elsif($question eq 'n'){print 'No file was written'}#if user doesnt want to overwrite, dont else{print 'incorrect entry, please reenter'; #if wrong entry &overwrite; #restart asking question if you want to overwrite } #end else statement }#end sub overwrite sub makefile{ open(MAPDIR, ">$mapfile") or die "couldn't open $dir";#opens text file directory my @files = readdir(DIR);#opens and puts directory names into DIR closedir(DIR); #closes directory $listpos = 0;#sets listposition at 0 for until loop until($listpos > $#files){ #until the list position is greater than the #number of files in the dir ($filnam, $ext) = split(/\./, $files[$listpos]);#splits each file into name and extention if($ext eq 'bsp'){#only prints to text file if it is a bsp print MAPDIR "$filnam\n";#prints map name to the text file } $listpos += 1; #adds one to the loop to make it read the next file and so on.... } print 'File written successfully'; }