Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: structured printing of arrays

by jasonk (Parson)
on Apr 24, 2003 at 03:11 UTC ( [id://252752]=note: print w/replies, xml ) Need Help??


in reply to structured printing of arrays

There's Text::ASCIITable.

Replies are listed 'Best First'.
Re: Re: structured printing of arrays
by hacker_j99 (Beadle) on Apr 29, 2003 at 06:14 UTC
    Perfect! Text::ASCIITable works great and does most things for me. In either ascii or in html table format...
    #!/eng/local/bin/perl # table maker require '/home/top/hfranks/perl/ASCIITable.pm'; # database hack require "../mysql_handeler.pl"; require "../template.pl"; #new table $t = new Text::ASCIITable; $user="hfranks"; @id=mysql_handeler('select uid from users_student where name="'.$user. +'";'); $uid=$id[1]; #mysql statements @res=mysql_handeler('select * from EECS2550 where uid="'.$uid.'";'); chomp @res; #column title @top=split(/ /, shift(@res)); #remove 2 unwanted auto_increment fields shift (@top); shift (@top); $t->setCols(\@top); #get rows foreach $line (@res){ chomp $line; @ary = split(/ /, $line); #remove two unwanted auto_increment fields shift (@ary); shift (@ary); $t->addRow(@ary); } #print it #normal ascii output #$cOntent .= $t->draw(); #advanced html output $cOntent.=$t->draw( ['<table border="1">','','',''], # <table><tr></tr> ['<tr><td>','</td></tr>','</td><td>'], ['','','',''], ['<tr><td>','</td></tr>','</td><td>'], ['','</table>','',''], ); my $template = "../template.html"; my %gTokens=(); my $key="<!--something-->"; $gTokens{"$key"} = $cOntent; &SendTemplate($template,%gTokens);
    html result:

    test1 test2 test3 quiz1 homework final
    100 100 100 10 100 100

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://252752]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-04-24 11:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found