bangor has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks, I have a CGI script which is called with a trailing path:
http://www.example.com/script.pl/foo/bar
To get the individual elements of the path I use a subroutine
http://www.example.com/script.pl/foo/bar
To get the individual elements of the path I use a subroutine
I'm a bit wary of this as I'm sure I've read that parsing anything from the web is error prone. My question is - is there anything inherently dangerous about this approach, and should I just use a module?sub get_paths_from_url { my $path = $ENV{'PATH_INFO'}; return if not $path; $path =~ s|^/||; $path =~ s|/$||; my @paths = split('/',$path); return \@paths; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Accessing %ENV directly in script
by afoken (Chancellor) on Dec 11, 2013 at 20:15 UTC | |
by bangor (Monk) on Dec 11, 2013 at 20:51 UTC | |
Re: Accessing %ENV directly in script
by educated_foo (Vicar) on Dec 11, 2013 at 20:19 UTC | |
Re: Accessing %ENV directly in script
by taint (Chaplain) on Dec 11, 2013 at 19:46 UTC |
Back to
Seekers of Perl Wisdom