Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Regular Expression help

Status
Not open for further replies.
What have you tried so far?

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
So far I have tried

my $referer = new URI($q->referer);
#gives you the url

$referer =~ m!/(.*)/!;
#extracts between first and last /

$referer =~ m!$1(.*)\?!;
#extracts from what ever was extracted by statement 2 till ?

prints $1;
#prints file name

seems to be working but I am sure there are shorter and easier ways of doing this..

Thanks for looking into the matter.

rak
 
How about:
Code:
my $referer = new URI($q->referer);
my ($filename) = $referer =~ m#.*/(.*)\?#
print $filename;
 
Wow, thats what I wanted.

Thank you,

Appreciate it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top