> > Howdy list.
> > I'm trying to one lineify this:
> >
> > my $guts = $firstchoice || '';
> > if(!$guts && $use_second_choice_if_first_is_empty) {
> > $guts = $secondchoice;
> > }
> >
> > Basically
> > my $guts = $firstchoice || $secondchoic || '';
> > Would be perfect except I only want to let it use $seconchoice if
> $use_second_choice_if_first_is_empty has a true value.
> > This does not work like I want but illustrates the goal if
> you read it
> our loud.
> > my $guts = $firstchoice || $secondchoic if
> $use_second_choice_if_first_is_empty || '';
> >
> > Is that possible to do with one line?
> >
> > TIA
> >
> > Dan
>
> Seems like the ternary operator should set you up... perldoc
> perlop look for "Conditional Operator"...
>
> my $guts = (($firstchoice ne '') ? $firstchoice :
> (($firstchoice eq '') ? $secondchoice : ''));
Thanks! I'll try each of these suggestions and maybe Benchmark them for grins.
>
> Though there may be a better way using some combination of
> ||= or am I misunderstanding you completely?
>
http://danconia.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>