Bryan Harris wrote: > > > I'd like to concatenate two variables-- > > > > > > $newVar = $old1 . $old2; > > > > > > -- where $old1 might be undefined. Is there any way to set a > > > flag so that this just results in $old2 instead of the compiler > > > throwing an error? > > > > The concatenation operator will work fine with an undefined value. > > It's one of the cases where the interpreter will substitute an > > empty string instead of throwing an error. > > That's good to know... > > It looks like I've over-simplified. I'm "concatenating" two > variables into a list: > > $newTxt[$row] = [ @{$numTxt[$row]}, "\t" x ($nextCol - $#{$numTxt[$row]}), @temp ]; > > I'd like result to be @temp if $numTxt[$row] is undefined, and that > whole mess if it isn't. It seems like this should be done without an > if/then, but I can't see how.
Without any fancy stuff it goes like this: if (defined my $hash = $numTxt[$row]) { $newTxt[$row] = [ @{$numTxt[$row]}, ("\t") x ($nextCol - $#{$numTxt[$row]}) ]; } else { $newTxt[$row] = [ @temp ]; } Note the parentheses around "\t". If you leave these off you get a single string containing the given number of tab characters instead of an array of single tabs. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]