in reply to Two hash keys created when '.' is in the string
$uniques{"$2.cfm"}++;
Increments the value stored under hash key "$2.cfm". If you haven't set it to anything, it'll end up with a value of 1 (0 + 1 = 1) :)
You then set the value of hash key "$2" to '<cust>'.
In your modified version, the line:
Is redundant, since you're overwriting the value on the next line. I think you're looking for something like this:$uniques{"$2"}++;
while ($_ =~ /(<cf_)(.*?)[>\s]/gi) { # finding custom tags $uniques{$2}++; }
Then you can print out a list of how many times each custom tag is being called with something like this:
Or, do whatever else you want with the results...while (my ($code, $count) = each %uniques) { print "$code => $count\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Two hash keys created when '.' is in the string
by yacoubean (Scribe) on Nov 24, 2004 at 18:16 UTC | |
by Eimi Metamorphoumai (Deacon) on Nov 24, 2004 at 18:31 UTC | |
by eric256 (Parson) on Nov 24, 2004 at 18:48 UTC | |
by ikegami (Patriarch) on Nov 24, 2004 at 19:04 UTC | |
by Eimi Metamorphoumai (Deacon) on Nov 24, 2004 at 18:55 UTC | |
by eric256 (Parson) on Nov 24, 2004 at 19:07 UTC | |
by ysth (Canon) on Nov 24, 2004 at 23:36 UTC |