On Thursday, May 30, 2002, at 08:28 , Rohesia Hamilton Metcalfe wrote:
> # pick one at random
> srand;
> $RandomScript = $Scripts[int(rand(@Scripts))];
>
> #here's the non-working regex:
> $ScriptName =~ s/$RandomScript/\w{3,}\b/;
>
> $RandomScriptURL = "path/".$ScriptName.".htm";
>
> ##################################
>
> Everything here is working except my attempt at a regex. I'm trying to
> get rid of "f-" at the begining and the ".cgi" at the end. I thought
> \w{3,}\b would get me the first block of word characters that came in a
> set of three or more until the end of the word. I'm getting nothing at
> all from this and am not sure what I'm missing.
[..]
I absolutely agree with Jeff 'japhy' Pinyan <[EMAIL PROTECTED]>
on the main thrust since a simple piece of perl like
my @Scripts=("f-aaaa.cgi", "f-bbbbbb.cgi", "f-cccc.cgi", "f-dddd.cgi",
"f-eeeeee.cgi", "f-ffffff.cgi");
# pick one at random
srand;
my $RandomScript = $Scripts[int(rand($#Scripts + 1))];
print "J Randome Script name :$RandomScript:\n";
#
# now to make it sans f- with
my ($ScriptName) = $RandomScript =~ /(\w{3,}\b)/;
print "J Randome Script name :$RandomScript: undt :$ScriptName:\n";
will show you that you get into $ScriptName - what you want.
I am also a bit concerned with trying to seed rand() with a
list, rather than say, the count of the list as noted above.
never be afraid to step aside, whip out a silly bit in YourTmpDirHere
and bash the semantics till it does what you really want...
since you do recall that it provides for a random value
from 0 to less than expr - hence you want (index + 1) so
that you can get your last element in the list....
ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]