in reply to Dealing with Use of uninitialised Values warning
return 0 unless @_; return $var1 if @_ == 1;
This may seem like a lot of work to you, but at least it makes explicit the behavior of your code with, um, nonstandard arguments.
And in regard to ||=, personally I think it's a pretty elegant operator, but perhaps you might like this better:
Again, this makes things *more* explicit than they were. Maybe that isn't what you had in mind when you said "better" :)my $var1 = shift || 0; my $var2 = shift || 0;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Dealing with Use of uninitialised Values warning
by kiat (Vicar) on Nov 20, 2004 at 08:12 UTC |