use strict; use warnings; use URI::Find; use File::Basename; # add more if needed my @suffix = qw(.jsp .html .asp .htm); # optionally open a file here and replace DATA # with the name of the filehandle you opened my $data = do {local $/;}; my $finder = URI::Find->new(\&call_back); $finder->find(\$data); sub call_back { my $uri = shift; my %q = $uri->query_form; my $content = $q{content}; # using split like this is a hack ... improvements anyone? my (undef,@key) = split(/\//,dirname($content)); # this will add the file name minus its extension push @key, basename($content,@suffix); # you could push these to an array instead of printing print "Filename: {", basename($content), "}\n"; print "Keys: {", join(',',@key), "}\n\n"; } __DATA__ http://www.yyy.com/store/application/meraqf?origin=rrr.jsp&event=link(goto)&content=/asp/administrative/catalog/products/Network/benefits.jsp is this text automatically 'ignored'? yes, it is ;) http://foo.com/?content=/asp/management/catalog/products/Network/propaganda.asp http://foo.com/?content=/path/to/bar.html