<rant> Have you ever tried to read perl documentation, or a book about perl? How many times have you actually tried to run the code snippets that you post at PM? If you ever have done that, did you ever try looking up and understanding what the error messages mean? </rant>
In the present case, what is the goal of the subroutine? What does "priority" mean as it applies to files, and what sort of information about the files is needed to determine their priority?
In other words, if the goal of the subroutine is to return just the name of one file that is supposed to have the highest (or lowest?) priority, can you describe in plain English how that one file should be selected? Or if the goal is to return a ranked list of files (sorted according to increasing or decreasing priority), what are the criteria for ranking the files?
If you have trouble answering those questions (in plain English, or maybe pseudo-code), then there's no point in us trying to correct all your various mistakes and misunderstandings about perl syntax (which you should have learned by now from perldoc or a decent book).
Based on the perl you've posted here, I can't guess what you're trying to accomplish, but I can see that your approach is seriously confused. Please try to organize your thoughts and explain things as clearly as you can.
One more request: The next time you decide to post some of your code, run it through perl first, and read the syntax errors and warnings that result. The way to do that is: store the code in question into a file (e.g. "test.pl"), and run the following command:
perl -cw test.pl
Then edit the code to try and correct the things that cause the errors and warnings. Repeat until all the errors and warnings are gone, or until you decide that you really can't figure out how to fix them. Then post the code here.
If you are posting code that still causes errors or warnings, make sure to include all those messages (don't just summarize or paraphrase them). That way, the question becomes "How do I fix these?"
If you are posting code that "runs" (no errors), but still doesn't do what you want, you really need to make it clear what you want it to do, and how that differs from what it is actually doing. The question is then "What is the right way to do this?"
I think you'll make much better progress in general that way (and you'll have a much better time at PerlMonks). If you won't do that, be prepared for a higher quantity of negative votes and ranting replies on your nodes here -- and little or no real progress. |