Trouble with CGI and table looping

I'm trying to create a table using cgi, populating it with content from an array, but I can't seem to find any answers online that solve my issue. I only have experience in languages like Java, and C++, so I'm not entirely sure what I'm doing when it comes to scripting, but here's what I have.

$c -> start_html(-title=>'Hello World'),

$c -> start_table({ -border => 1, -width => %50},
    while($i <= 4){
            $c -> tr({
                while($j <= 7 && $i + $j <=26){
                    $c -> td($alpha[$i + $j]),
                    $j++,
                }}),
            $i++,
    },
$c -> end_table,

$c -> end_html;

In my mind this seems like it would work, but it keeps returning a compilation error at while($i <=4), and says nothing else about the error. I could really use some help understanding this.

Answers


To get the same effect as what you're trying to do, you could use the "map" function with a range and you'd end up with something like this.

my $i=0;
$c->table({-border=>1, -width => "%50"},
    map { $c->Tr(
        map { $c->td(($i<=26 ? $alpha[$i++] : ""),
            ); } (0..7)
        ) } (0..4)
    );

Need Your Help

State Machine Rails 4 doesn't back to the initial state

ruby ruby-on-rails-4 state-machine

I need a little help with state machine because I'm working with rails 4 I have a initial state called in_analysis and other states called approved and reject and the states approved and reject wo...

flash builder 4 - annoying error message while "validating server configuration"

eclipse configuration flash-builder

As I haven't yet streamlined my configuration/project management yet, I keep reorganizing the project structure and workspace. Similarly I keep changing apache's webroot. Every time I change it, I ...