in reply to Re: Error while taking 'Scalar of scalar'
in thread Error while taking 'Scalar of scalar'

my $color = $colors[rand @colors];
Or
my $color = $colors[int rand @colors];
which does the exact same thing, but doesn't depend on the knowledge that numbers used as array indexes are truncated to integer, instead of rounded.