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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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


In reply to Re: Re: structured printing of arrays by hacker_j99
in thread structured printing of arrays by hacker_j99

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-20 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found