in reply to Re: How to detect a hash container key from a referenced sub value
in thread How to detect a hash container key from a referenced sub value
First, I want to say, I've made some typos in my code. I've used '=' instead of '=>' in hashes and I've forgot to apply a value in the subroutine. I fixed it now.
Anyway.
The obvious, as you say, yes. That's how I usually do it. I, usually, create a sub, supply the values explicitly to it and get the result. I just wanted to see, if it's possible to do it implicitly, also, I need that total value in the variable, because I am going to sort it by qtyTotal in dec order, by using a sort function. If it's not going to be automatically updated, I figure that I have to create an other temp variable, every time I use that sort function. I just wanted to see, if could it be done in a more elegant way. Also, it will eliminate any bugs, that could be caused by forgetting of updating a qtyTotal in that variable.
I guess, you are right about creating object instead of just using a regular variable.
I was hesitant with that because, the only time, I've used objects is when I refer to other libraries or modules and what always stopped me was that, i might be wrong, the requirement to create a module, describing the object in the separate file instead of just ability to make an object in the same file as the script. :(
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to detect a hash container key from a referenced sub value
by almut (Canon) on Dec 03, 2009 at 11:52 UTC |