Created
February 15, 2013 19:55
-
-
Save jacoby/4962998 to your computer and use it in GitHub Desktop.
TIL that you can have query strings without query strings. Man, I wish I knew this a decade ago.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict ; | |
use warnings ; | |
use 5.010 ; | |
use CGI ; | |
use CGI::Carp qw( fatalsToBrowser ) ; | |
use Data::Dumper ; | |
use lib '/home/ltl/lib' ; | |
use LTLcommon qw{ pi_Readfile } ; | |
$LTLcommon::UseTestFiles = 0 ; | |
my $q = new CGI ; | |
print $q->header() ; | |
print $q->start_html( | |
-style => '/~jacoby/env.css', | |
-title => 'TEST', | |
-head => $q->Link( { | |
-rel => 'icon', | |
-type => 'image/vnd.microsoft.icon', | |
-href => '/~maize/Images/favicon.ico', | |
} | |
), | |
) ; | |
print main( $q ) ; | |
print $q->end_html() ; | |
#---------- ---------- ---------- ---------- ---------- ---------- ---------- | |
sub main { | |
my ( $q ) = @_ ; | |
my $pi_readfile = pi_Readfile() ; | |
my @pi_list = sort keys %$pi_readfile ; | |
my $param ; | |
%$param = map { $_ => $q->param( $_ ) } $q->param() ; | |
my @path = grep { /\w/ } split( /\//, $q->path_info ) ; | |
my $path = $path[0] ; | |
my $url = $q->url() ; | |
my $output ; | |
$output .= $q->div( $url ) ; | |
$output .= $q->div( $path ) ; | |
if ( $path && $pi_readfile->{ $path } ) { | |
my $pi = $pi_readfile->{ $path } ; | |
$output .= $q->pre( Dumper $pi ) ; | |
} | |
else { | |
for my $pi ( @pi_list ) { | |
my $link = join '/', $url, $pi ; | |
$output .= $q->p( $q->a( { href => $link }, $pi ) ); | |
} | |
} | |
return $q->div( $output ) ; | |
} | |
#---------- ---------- ---------- ---------- ---------- ---------- ---------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment