in reply to Re: cv = (irand(2))?"+":"-";
in thread cv = (irand(2))?"+":"-";

It works:

sub example { do { $av = irand(11) + 10; $bv = irand(11); $cv = irand(2) ? "+" : "-"; } until ( !( $av - $bv < 0 || $av + $bv >= 20 ) ); print $av. $cv . $bv . " = \n"; }

Replies are listed 'Best First'.
Re^3: cv = (irand(2))?"+":"-";
by kennethk (Abbot) on Apr 05, 2016 at 16:22 UTC
    Your print could be written more succinctly as
    print "$av$cv$bv = \n";
    For delimiters that interpolate like double quotes, blackslashed characters are converted to the appropriate whitespace or control character and scalars ($) and arrays (@) are converted to their contents as strings. See Quote and Quote like Operators in perlop for detail.

    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.