in reply to Re: default values for lists
in thread default values for lists
my ($end) = $word =~ /(e?s)$/ || (''); ... #do something with $word $word = "$word$end";
If the word does not end in s/es, I get a warning about uninitialized variables where I append $end - which I wanted to avoid.
I thought about the ternary, but I don't want to evaluate the regex twice.
I simplified the problem because IMO it boils down to the question if I can enforce list context on the part before the ||. But maybe I oversimplified it.
Thanks anyway for the suggestion.
pike
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: default values for lists
by fglock (Vicar) on Sep 17, 2002 at 17:33 UTC | |
|
Re^3: default values for lists
by Aristotle (Chancellor) on Sep 17, 2002 at 21:14 UTC |