> > 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 : ''));
Except I only want to assign $secondchoice to it if $use_second_choice_if_first_is_empty is true. BTW - I'm not really using these variable names, only using them here ot help clarify my goal. Bob's woprks perfect and I havn';t tied Driex's as I have to leave right now. I'm going to benchmark them and see if there is any performance gain in either, though I doubt it. Thanks > > 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>