I assume you got it running, its just when I tried it, the script hung on the while statement. (I was running it off Perl on windows and see you were using it on a Unix system or something - not that it should make a difference though)
Anyway, I just coded up my own version, (complete with comments on what each line does) that:
1. Gets the SSID’s from your file
2. Sorts them into alphabetical order (well actually ASCII code order)
3. Removes any duplicate id’s.
4. Writes the SSID only list back to a file.
5. Prints the list on screen
So feel free to take a look through it any try and add the functions to your version if you like.
#!/usr/bin/perl
#######Set Variables#################
$data_file="cs_waps.txt"; #
$data_out_file="cs_waps_ssids.txt"; #
#####################################
system("/usr/bin/clear"); # Clear the screen on Unix
#system("cls"); # Clear the screen on Windows
###Read date from file
open(DAT, $data_file) || die("Error # Open file in read only mode
opening data file \"$data_file\"");
@raw_data=; # Read stuff into an array
close(DAT); # Close file
@sortedarray=sort(@raw_data); # Sort all the file contents simply by
# the ASCII value of the characters
foreach $line (@sortedarray) # For every line in the file
{
chop($line); # Take the carrige return off the end
($is_ssid,$ssid)=split(/\ /,$line); # Split the line into sections that are
# Separated by a space character
if ($is_ssid eq "SSID:") { # If the first part of the line is SSID:
$all_ssids =~ s/$ssid\n//; # Check to see if the list allready has
# the ssid (if so take it out)
$all_ssids= $all_ssids . $ssid . "\n"; # Add the ssid to the list in the string
# And separate them with a new line (\n)
} # End the SSID if statement
} # End the "foreach $line" loop
###Write the ssid's to a file
open(DAT,">$data_out_file") || die("Error # Open file in write only mode
opening data file \"$data_out_file\"");
print DAT "SSIDs\n"; # What we want in the file
print DAT "-----\n\n"; # What we want in the file
print DAT "$all_ssids"; # What we want in the file
close(DAT); # Close file
###Display the info on screen
print "\nSSIDs\n"; # Print out a fancy heading
print "-----\n\n"; # Underane our fancy heading
print "$all_ssids"; # Print out all the ssid's

I just checked through the code, and the board messed it up, as it thinks im using HTML tags, so if you want the proper code that will work, download it from
here.