print "Say ", ( m!([^,]+)!g )[ scalar rand( tr!,!! ) ], "\n";
Counting the commas will give you one less than the numbers of elements in the list so you have to add one to it:
print "Say ", ( /[^,]+/g )[ rand 1 + tr/,// ], "\n";
In reply to Re^2: Pick random item from list of unknown length?
by jwkrahn
in thread Pick random item from list of unknown length?
by Cody Fendant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |