use a hash for many reasons. Speed the best.

your main statement would be
%hash{$variable}++;

have $variable = the two digitcode read from the file.

This statements will make create an a new element if it doesn't exist
and it will set the count to 1. Since it would be normally created as
undef or 0 depending on how you used it. Since your using it
mathematically the compiler assumes 0.

I use this sort of hash for all kinds of things!!

Hope that helps.



> -----Original Message-----
> From: Ray Seals [mailto:[EMAIL PROTECTED]] 
> Sent: Thursday, January 02, 2003 4:57 PM
> To: Perl
> Subject: Use a hash or multi dimensional array?
> 
> 
> DISCLAIMER:  I'm new to programming other than a little bit 
> of scripting for cron jobs.
> 
> I'm parsing a comma delimited file for a specific 2 letter 
> code on each line in the file.  Once I find that 2 letter 
> code I want to increment a count value and store it.
> 
> I've thought about putting it into a 2 dimensional list that 
> would hold the 2 digit code and a count.  So every line I 
> process would look for that 2 letter and the count value.  If 
> it finds it, read it in along with the count value.  
> Increment the count value.  Remove the old count along with 
> the 2 letter code using a pop.  Then push the new value and 2 
> letter to the list.
> 
> The only reason I keep looking at a hash is because I need to 
> sort the list when I do my reporting.
> 
> I thought about taking the cheesy way out and use a 
> case/switch setup, but I won't always know what the 2 letter 
> codes will be.
> 
> 
> -- 
> Ray Seals <[EMAIL PROTECTED]>
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to