Or $file_data{$id}++; Like someone else said! Duh sorry, brain dead Dan
-----Original Message----- From: Dan Muey Sent: Thursday, January 02, 2003 4:13 PM To: Ray Seals; Perl Subject: RE: Use a hash or multi dimensional array? %file_data = (); # open file @lines = <FILEHANDLE>; # close file foreach $line(@lines) { $line =~ s/\n|\r//g; ($id, $ct) = split(/,/, $line); if($id =~ m/^\w\w$/) { $ct++; $file_data{$id} = $ct; } $id = ''; $ct = ''; } Dan -----Original Message----- From: Ray Seals [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 02, 2003 3: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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]