have you ever wondered why you only get back the first two colors? rand(x) returns a random number between 0 and (excluding) x.my @color= qw( lavender lightblue honeydew); my $color_no=int(rand($#color)); return $color[$color_no];
the usual idiom for this in perl is:
my @colors = qw(lavender lightblue honeydew); my $color = $colors[rand @colors]; return $color;
In reply to Re: Error while taking 'Scalar of scalar'
by tinita
in thread Error while taking 'Scalar of scalar'
by cool
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |