Gossamer Forum
Quote Reply
Random - but words
This global works great at producing random characters:

sub {
my @random = (0 .. 9, 'a' .. 'z', 'A' .. 'Z');
my $rand = '';
for (1 .. 8) {
$rand .= $random[rand @random];
}
return $rand;
}

<%random%>


But what if you wanted to produce a string of text set in the global itself like:

ford cars
triumph bikes
daf trucks

- then the global chose anyone of these to return.

any ideas?

--------------------------------
Privacy Software
Quote Reply
Re: [BLOOD] Random - but words In reply to
Maybe something like this?

Code:
sub {
my @words = ('ford cars','foo bar','another test','yay');
my $word = $words[rand @words];
$word ? return $word : return 'No word';
}

That *should* grab a random entry from the @words array. Please note, this is untested, so may not work without a couple of minor mods :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Random - but words In reply to
Works very good and very usefull Cool

Thanks.

--------------------------------
Privacy Software