[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] random_string() persistant?
> >I'm using the random_string() function in a usertag called
> >random_string_value.
> >
> >Looks like this:
> >
> >UserTag random_string_value Order tag
> >UserTag random_string_value Routine <<EOR
> >sub {
> >return random_string();
> >}
> >EOR
> >
> >Accessed like this:
> >
> >[random_string_value]
> >
> >The problem is that if I access a page with this on it, it is random the
> >first time, but subsequent accesses render a non-unique string
> that is the
> >same as the one before it.
> >
> >Any ideas?
>
> Does WFM count? :-) You can look through the code underneath it to find
> out what is causing the problem, but I think you will find that
> it is only
> random for every second that passes (i.e. you have to wait one second to
> get another random value). HTH,
>
> --
> /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\
> | Dan Browning, Kavod Technologies <dan.browning@kavod.com> |
> | (360) 882-7872 x7, 6700 NE 162nd Ave, Suite 210, Vancouver, WA |
> \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/
Dan,
What's WFM? Thank you, but I don't think that's it. Here's the sub in
Util.pm
## random_string
# leaving out 0, O and 1, l
my $random_chars =
"ABCDEFGHIJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789";
# Return a string of random characters.
sub random_string {
my ($len) = @_;
$len = 8 unless $len;
my ($r, $i);
$r = '';
for ($i = 0; $i < $len; ++$i) {
$r .= substr($random_chars, int(rand(length($random_chars))), 1);
}
$r;
}
I can access this several minutes apart and still have the same problem.
-RM