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?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: URL $ENV variables
by sgifford (Prior) on Aug 04, 2003 at 08:43 UTC | |
Re: URL $ENV variables
by antirice (Priest) on Aug 04, 2003 at 08:29 UTC | |
by bodmin (Sexton) on Aug 04, 2003 at 08:35 UTC | |
by antirice (Priest) on Aug 04, 2003 at 08:45 UTC | |
by sgifford (Prior) on Aug 04, 2003 at 09:36 UTC | |
by Anonymous Monk on Aug 04, 2003 at 22:35 UTC | |
Re: URL $ENV variables
by snowcrash (Friar) on Aug 04, 2003 at 08:38 UTC | |
Re: URL $ENV variables
by jsprat (Curate) on Aug 04, 2003 at 08:47 UTC | |
Re: URL $ENV variables
by naChoZ (Curate) on Aug 04, 2003 at 12:54 UTC | |
Re: URL $ENV variables
by chanio (Priest) on Aug 05, 2003 at 02:00 UTC |