<?xml version="1.0" encoding="windows-1252"?>
<node id="504596" title="Count and List Items in a List" created="2005-11-01 09:53:59" updated="2005-11-01 04:53:59">
<type id="115">
perlquestion</type>
<author id="494572">
Tech77</author>
<data>
<field name="doctext">
Hi Monks,  I have just started using Perl at work to help out with tasks here and there so I am new to this.  Recently, I created this script to grab a list of records from a database.  It actually works!  I'm pretty thrilled.

&lt;code&gt;
open (FILE, "userstab.txt") || die "Cannot open file.\n";

open (NEWFILE, "&gt;results.txt") || die "Cannot find or open file for editing.\n";

while (&lt;FILE&gt;) {
	@zapschool = split (/\t/);
	if (m/zaps/i) {
		print NEWFILE "$zapschool[4]\n";		
	}
}

close FILE;
close NEWFILE;
&lt;/code&gt;

&lt;p&gt;This gives me a list of all the entries in a column, but now I need to figure out how to use Perl to go through my new list, results.txt, and create a new list that holds the names and a count of how many times a partcular name appears on the list.&lt;/p&gt;

&lt;p&gt;For example, my list contains college and university names.  Many of them appear multiple times.  I'd like to create a list where each unique record appears only once but with a frequency count of how many times it appears.&lt;/p&gt;

&lt;p&gt;Can you offer some guidance on how to proceede?  I'm not necessarily looking for finshed code, but more a point in the right direction so I can do it myself.  Thank you.&lt;/p&gt;</field>
</data>
</node>
