in reply to Re: HTML table creation
in thread HTML table creation

Thanks tobyink for your answer, I've tried to do that but obviously I couln't manage to do that. I've tried to make a sub routine for a WHILE loop and call it as a reference, but no success. Any suggestion of how to do it in one line ?

Replies are listed 'Best First'.
Re^3: HTML table creation
by tobyink (Canon) on Jul 28, 2012 at 09:24 UTC

    This does it:

    my @Head = ("Anv. ID", "F\xF6r", "Efter", "Pref", "Bef", "Nytt", "Pr", + "F\xF6r", "Kap"); open my $temp, '<', $tempfil or die "Kan inte \xF6ppna filen $tempfil"; print $qry->start_form(-action => "http://skinnmaskin/cgi-bin/kon.cgi" +); print $qry->table( { Border => 1, Cellpadding => 5, bordercolor =>"#FFFFFF" }, Tr(map { th($_) } @Head), (map { my ($Uid, $Fn, $En, $Pr, $Ank, $Ext, $Or, $Adr) = split m{[|]} +; Tr( td(textfield('UID', $Uid, 6)), td(textfield('FNA', $Fn, 20)), td(textfield('ENA', $En, 35)), td(textfield('PRE', $Pr, 10)), td(textfield('BEF', $Ext, 16)), td(textfield('NYTT', $Ank, 5)), td(checkbox('')), td(checkbox('')), td(checkbox('')), ); } <$temp>), #/map ); #/table

    Untested of course, as I don't have a copy of your input data. There are certainly better ways to do it (the HTML generation functions of CGI.pm are not how I'd go about generating HTML at all) but it sticks pretty closely to your original code.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

      Thanks man, Works exactly as I wanted. Obviously I didn't know you could use map function in that way, thanks for learning me.

Re^3: HTML table creation
by Anonymous Monk on Jul 28, 2012 at 09:24 UTC

      Hej and thanks for your reply. I'll take a look at it for sure.