Skip to content

Instantly share code, notes, and snippets.

@viklund
Created June 6, 2009 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viklund/124830 to your computer and use it in GitHub Desktop.
Save viklund/124830 to your computer and use it in GitHub Desktop.
#!/home/johan/perl6/rakudo/perl6
sub unescape($s is rw) {
my $string = $s;
$string .= subst('+', ' ', :g);
# RAKUDO: This could also be rewritten as a single .subst :g call.
# ...when the semantics of .subst is revised to change $/,
# that is.
while $string ~~ /\%(<[0..9A..F]>**2)/ {
my $match = $0;
my $character = chr(:16($match));
$string .= subst('%' ~ $match, $character);
}
return $string;
}
print "Content-Type: text/html\n\n";
say '<html><head><meta content="text/html; charset=utf-8" http-equiv="Content-Type" />';
say '<title>Test</title></head><body>';
say "<p>Hej";
say '<form method="POST" enctype="application/x-www-form-urlencoded">';
#say '<form method="POST" enctype="multipart/form-data">';
say '<textarea name="articletext" rows="22" cols="60"></textarea>';
say '<input type="text" name="tags" size="50" value="" />';
say '<input type="submit" value="Save" />';
say '</form>';
say '<hr>';
say "<dl>";
for %*ENV.kv -> $k, $v {
say "<dt>$k</dt> <dd>$v</dd>";
}
my $tmp = open( 'tmp6.txt', :w );
my @stuff = ();
say "<dt>STDIN</dt><dd><pre>";
for $*IN.lines -> $l {
say $l;
@stuff.push($l);
$tmp.say($l);
#say $tmp $_;
}
$tmp.close;
say "</pre></dd>";
say '<dt>Decoded</dt><dd>';
for @stuff -> $l {
say unescape($l);
}
say '</dd>';
say '</dl>';
say '</body></html>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment