mellin has asked for the wisdom of the Perl Monks concerning the following question:
#!/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"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: About PATH_INFO and SSI
by Mr. Muskrat (Canon) on Dec 07, 2004 at 02:11 UTC | |
|
Re: About PATH_INFO and SSI
by sgifford (Prior) on Dec 07, 2004 at 06:38 UTC | |
by mellin (Scribe) on Dec 07, 2004 at 10:14 UTC |