You forgot to say what is wrong with your program or why it does not fit your purpose or how it is not giving you the expected result. How are we supposed to guess? You basically failed to give us the most important piece of information to help us helping you to solve your problem.

Well, I nonetheless have a guess. If I understand correctly what you are trying to do, I would think that your error is probably in this line of code:

Code

$C_list{$line} = 1

I would suggest that you change it to this:

Code

$C_list{$line}++;

so that you actually count the number of times $lines occurs in your input, rather than setting the counter to 1 each time.

There may be some other problem in your program, but I will not investigate further so long as you don't provide us with information about what is wrong in your program. Try to make the change I proposed, and, if this still does not work, please tell us in which respect you are not getting the result you are looking for.

As a side note, you don't need to do this:

Code

} else {

}

An else statement is never required in an if conditional, just omit it if you don't need it:

3. YES... I realized after my posting that the } else { ... statement was unnecessary and removed it.

I changed the line you suggested but that did not fix things. I was trying to decide about a counter, but thought perhaps it was maybe needed down in the foreach loop section.

What I want to do is for the Output to be ONLY "Duplicates" greater >1 entry from the original list. I think maybe I am misunderstanding the keys % (etc) part of things as well. It should be pretty simple but I'm just plain stuck.

Ohhh... I didn't see your new reply before making some other comments.

Just tried your code snippet and that eliminated the previous compliation error I could not figure out, however I am still getting the "Global symbol "$value" explicit package error. That has me stumped.

I tried numerous additional code variations with no success, so decided to take a different approach to try and understand what's going on.

So I created a Test Hash with 3 entries, 2 of them being duplicates (but assigned a duplicate count value). The results are what I want EXCEPT are NOT sorted alphabetically within the same group number of duplicates - in this case 2. I used a single (NON-Duplicate) value of 1 for the test entry "NONDUPE" - like the majority of the original list entries will be and to NOT be included in the output:

Code

#!/usr/bin/perl

#use strict; (REMOVED FOR IT TO WORK!!!) #use warnings; (REMOVED FOR IT TO WORK!!!)

The way it works is as follows: it compares numerically the values or numbers of occurrences ( the "$C_list{$b} <=> $C_list{$a}" part), and, if the values are equal, it compares the keys alphabetically.

The way it works is as follows: it compares numerically the values or numbers of occurrences ( the "$C_list{$b} <=> $C_list{$a}" part), and, if the values are equal, it compares the keys alphabetically.

Ohhhhhhh, Laurent, THANK YOU VERY MUCH for another very Educational Experience !!! I have learned several new things here.

I'm back up on a few hours of sleep and think part of a previous error was that I had not fully commented OUT a line of code that didn't work. At 70 years old, my eyesight is not the best ;-(

When I finally decided to copy & join the bottom section of the code that did partially work from my basic ground-up little Hash Test to the full front end $C_list section, I learned more about Hashes and that the less lines of code the better without a bunch of # lines. Also, to especially look for any "curly braces" issues trying to hide from me.

Your "explanation" of the final code snippet solution was extremely helpful to understand HOW it works !!!

So you travel to work on a train! As a youth, I was fascinated by trains, and had an elaborate model train set. Then later as teenager, I traveled ~ 2,000 miles round trip by train several Summers to visit relatives. But there were no computers, no cell phones, no tablets and no Internet back then. Times have changed !!!