On Apr 28, 2012, at 10:40 AM, sono...@fannullone.us wrote: > On Apr 28, 2012, at 7:32 AM, Lesley Binks wrote: > >> Says the $host identifier will be assigned the value 'localhost' only if >> $extra >> is not defined. >> >> But $extra is defined as 'mail.example.com' so $host won't be. > > That makes sense. What I'm trying to do is set $host to one of the two > values - if $xtra is set, use it; if not, use localhost. I was just trying > to get it as short as possible. Maybe I'll go back to the if statement I had > before. >
If you're using a new enough Perl -- v5.10 or newer -- you can use the super handy 'defined-or' operator for this: my $extra = something_that_may_return_undef(); my $host = $extra // 'localhost'; chrs, john. -- John SJ Anderson // geneh...@genehack.org -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/