in reply to Re^2: DBI select ids to @ids in thread DBI select ids to @ids
Why no selectcol_array?
I'm not sure. You could always email Tim Bunce and ask him.
However, dereferencing an array reference is easy. I really don't see a need for it.
Personally, I wouldn't dereference it into an array. You're not showing how your are using the @ids array but if you need to pass it around in your code, say as a parameter to another sub, you will probably want it as a reference anyway.
Re^4: DBI select ids to @ids
by tomazos (Deacon) on Aug 10, 2005 at 07:25 UTC
|
I agree that wrapping the whole call in @{} isn't hard, however amongst a large chunk of code its easy to mentally parse the brackets incorrectly, or confuse them with end of block delimiters.
I don't like passing things by reference unless either (A) the sub is going to modify it, or (B) it is so big that it is an efficiency concern. This is because the subroutine might modify it accidentally. Passing by value helps to isolate a bug to a smaller scope (or if the accidental modification doesn't effect the functionality of the sub - avoids it completely).
Plus its hard to keep track of what is a reference and what isn't, so I try to keep everything lexical and dereferenced to take advantage of the cleaner syntax.
-Andrew
| [reply] |
|