On Monday, June 2, 2003, at 06:54 PM, Stuart White wrote:

I don't understand this syntax:

$linehash{$1}++;

Could you explain it to me?

Absolutely.


This is a common Perl technique, often used with a hash named '%seen' because that's exactly what it's keeping track of. $1 is where you were capturing your names, I just made that the key to the hash and the ++ just increments the value. In long form it's $linehash{$1} = $linehash{$1} + 1. In english that's, "Add one to the value stored in %linehash at $1, replacing the old value." The first time a name is seen it's value will be undef, which conveniently numifies to 0.

Hope that clears it up a little. Good luck with your program.

James


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



Reply via email to