http://qs321.pair.com?node_id=280596

bodmin has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

If my url is http://www.perlmonks.com/index.pl?node=Seekers, I am trying to get my script name, i.e. index.pl.

I use $ENV{REQUEST_URI} to get the current url.

I have some params attached to the url which I access via $ENV{QUERY_STRING}.

So in order to get index.pl (as in the example above) I use the following:

$attach1 = $ENV{REQUEST_URI}; if($attach1 =~ /\\/){ my @filename_parts = split /\\/,$attach1; my $length = scalar(@filename_parts); $attach1 = $filename_parts[--$length]; } if($attach1 =~ /\//){ my @filename_parts = split /\//,$attach1; my $length = scalar(@filename_parts); $attach1 = $filename_parts[--$length]; }

The above gives me index.pl?node=Seekers, half way there.

To strip off ?node=Seekers I use the following:

$paramstr = "\?".$ENV{QUERY_STRING}; $attach1 =~ s/$paramstr/;

And that is where my code breaks. How do I strip off the query string so I am left with index.pl?