in reply to dividend with recursive routine
The sequence $100 appears in your double-quote delimited string on line 2. Because double-quote delimited strings interpolate (Quote and Quote like Operators), Perl sees this as a variable. The variable $100 is the hundredth capture buffer from a regular expression. Had you actually tested what you posted, perl would have thrown a warning (Use of uninitialized value in concatenation (.) or string). You should not be posting code that throws warnings unless the warning pertains to your question. See How (Not) To Ask A Question.
As we already discussed in counting number of occurrences of words in a file, why are you not using strict? If you opt not to use strict, why are you using my?
You should never use $a as an ordinary variable. It has special meaning for sort. The only one-character variables which are socially acceptable to use as generic variables are $i, $j, $x, $y and $z, because these have established meanings that predate Perl (and microprocessors). Any time you use a variable with a single character for its name, you run a very real risk of clobbering some internal Perl behavior.
Is your dividend 3.78% or 6.78%? Your code seems confused on that issue.
Why do you create a hash and then sort the keys on your hash for output when you already have those keys in order in @stocknum? Why not just iterate over an index, or at least use the existing array as your list?
Why do you concatenate two strings for your output? You are adding unnecessary operations, confusion and characters.
Why do you have a floating $dividend variable at the end of your script, who's only function is to throw another pointless warning?
Your indentation still leaves something to be desired. Check out perltidy as a way to make your code prettier.
|
|---|