monorels has asked for the wisdom of the Perl Monks concerning the following question:
Hi. Tell my please. Why this don't work? Thanks.
sub example { do { $av = irand(20) +1; $bv = irand(11) +1; $cv = (irand(2))?"+":"-"; } until (!($av $cv $bv >= 0 && $av $cv $bv <= 20)); print $av $cv $bv; }
gen.pl|38| Scalar found where operator expected at /home/monorels/iperl/gen.pl line 38, near "$cv $bv" (Missing operator before $bv?) 3 gen.pl|38| Scalar found where operator expected at /home/monorels/iperl/gen.pl line 38, near "$av $cv" (Missing operator before $cv?) 4 gen.pl|38| Scalar found where operator expected at /home/monorels/iperl/gen.pl line 38, near "$cv $bv" (Missing operator before $bv?) 5 gen.pl|39| Scalar found where operator expected at /home/monorels/iperl/gen.pl line 39, near "$cv $bv" (Missing operator before $bv?) 6 gen.pl|38| syntax error at /home/monorels/iperl/gen.pl line 38, near "$av $cv " 7 gen.pl|39| syntax error at /home/monorels/iperl/gen.pl line 39, near "$cv $bv"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: cv = (irand(2))?"+":"-";
by Corion (Patriarch) on Apr 05, 2016 at 08:20 UTC | |
by monorels (Novice) on Apr 05, 2016 at 08:55 UTC | |
by kennethk (Abbot) on Apr 05, 2016 at 16:22 UTC | |
by monorels (Novice) on Apr 05, 2016 at 08:40 UTC | |
by davido (Cardinal) on Apr 05, 2016 at 14:48 UTC | |
by Your Mother (Archbishop) on Apr 05, 2016 at 15:14 UTC | |
by monorels (Novice) on Apr 05, 2016 at 08:43 UTC |