
japhy
Enthusiast
/ Moderator
Nov 7, 2000, 4:47 AM
Post #2 of 3
(4367 views)
|
Re: Chopping up $env{REQUEST_URL}
[In reply to]
|
Can't Post
|
|
The directory name starts at the first / and goes to the last /, correct? No regex needed here at all. <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> my $bpos = index $ENV{REQUEST_URL}, '/'; my $epos = rindex $ENV{REQUEST_URL}, '/'; my $dir = substr($ENV{REQUEST_URL}, $bpos, 1 + $epos - $bpos); </pre><HR></BLOCKQUOTE> If you really want to use a regex, then I'd suggest: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> my ($dir) = $ENV{REQUEST_URL} =~ m!(/(?:[^/]*/)*)!; </pre><HR></BLOCKQUOTE> ------------------ Jeff "japhy" Pinyan -- accomplished author, consultant, hacker, and teacher
|