[Omaha.pm] Pick a random array element ... beware the web experts :)

Andy Lester andy at petdance.com
Mon Oct 23 17:00:37 PDT 2006


On Oct 23, 2006, at 4:33 PM, Jay Hannah wrote:

> print $a[int rand($#a + 1)];
>
> because $#a is not the number of elements, its the highest index of  
> @a.

All you really needs is @a[rand @a].

xoxo,
Andy

--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance






More information about the Omaha-pm mailing list