use strict; use warnings; use Plack::Request; use Plack::Response; my $app = sub { my $env = shift; my $req = Plack::Request->new($env); my $rows = 20; my $cols = 10; if ($req->method eq 'POST') { my $params = $req->parameters; my $output = "

Submitted Data

";
        for my $r (0 .. $rows - 1) {
            for my $c (0 .. $cols - 1) {
                my $key = "cell_${r}_${c}";
                my $val = $params->{$key} // '';
                $output .= sprintf("%-10s", $val);
            }
            $output .= "\n";
        }
        $output .= "
Back"; return [ 200, [ 'Content-Type' => 'text/html' ], [$output] ]; } my $html = <<"HTML"; PSGI Spreadsheet

Excel-like Grid

HTML # Column headers (A, B, C...) for my $c (0 .. $cols - 1) { my $label = chr(65 + $c); $html .= ""; } $html .= ""; # Rows for my $r (0 .. $rows - 1) { $html .= ""; $html .= ""; for my $c (0 .. $cols - 1) { my $name = "cell_${r}_${c}"; $html .= qq{}; } $html .= ""; } $html .= <<"HTML";
$label
" . ($r + 1) . "

HTML return [ 200, [ 'Content-Type' => 'text/html' ], [$html] ]; }; return $app;