in reply to Pass by reference: is it good form to grope @_?
> Is the @_ trick really an evil thing or am I being squeamish?On this question my vote is "guilty until proven innocent".
Sometimes the @_ trick is a good way to go. One common example is:
And then you call trim($a, $b) to trim leading and trailing whitespace from $a and $b.sub trim { for (@_) { s/^\s+//; s/\s+$//; } }
Cases like this come under the heading of 'doing something weird'. When you do something weird, you need to make sure people know about it. One thing that's important is to give the function a suggestive name. In your question you left out a crucial piece of information: The name of the method. All you told us was that it was called foo. But the name is very important here.
If you call the method is_yellow, then it's a very bad idea to have it modify its argument. But if it's called set_argument_to_57 then it might not be so bad.
|
|---|