Hey all, i have not so much as Perl related question, but more like CGI-stuff, and i would appreciate any wisdom about this.
I did a short script to parse 'PATH_INFO' variable, this script is used inside .shtml page with SSI. My pages now include links like '/index.shtml/id/335/' and so on. This works fine, if i run the script directly like '/cgi-bin/index.pl/id/335/', but if i try that former '/index.shtml/id/335/', my www-server just shows that index.shtml page, the index.pl script that is being called with SSI does not get the $ENV{'PATH_INFO'} variable.
Why is that so, is there any way to win this? It was a pleasant few hours already doing that perl-code, but now i would like to get this actually finished :)
Code parsing the PATH_INFO is shown below: (some finnish words inside blocks, but main logic should be clear)
#!/usr/bin/perl -w
use strict;
my $path = $ENV{'PATH_INFO'};
# omit the first '/' sign
$path =~ s/^[\/](.*)/$1/;
# read string like 'id/995/kk/2004-05/r/5' to @array
my @keys = split /\//, $path;
my %avain = ();
my $i = 0;
print "Content-type: text/html \n\n";
# let's go through all the indexes that split made
while ($i <= $#keys) {
# assign key-value pairs
$avain{$keys[$i]} = $keys[($i+1)];
$i = $i+2;
}
# for debugging purposes
while (my ($key, $value) = each (%avain)) {
next unless $value;
print "<p>$key = $value</p>\n";
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.