Forum Moderators: coopster & phranque

Message Too Old, No Replies

getting just the file name from REQUEST_URI in perl

         

jeremy goodrich

8:46 pm on Oct 23, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



After some digging (and a few lame attempts on my own part) I got this...

( $name ) = split( /[\?\#]/, $ENV{REQUEST_URI} );
( $name ) = ( $name =~ m#([^/]+)$# );

Just wondering if there is a faster and or easier way to do the above. Works well, and is better than the method I was trying to get working...

netcommr

1:24 am on Oct 24, 2001 (gmt 0)

10+ Year Member



$name = split( /[\?\#]/,$ENV{'REQUEST_URI'});
$name =~ s/^.*\///;

Regular expressions in perl are 'greedy'. They will match as much as possible in most cases. This example will remove everything up to and including the last forward slash (/).