magazine resources subscribe about advertising

New Architect Daily
Commentary and updates on current events and technologies

CMP Media E-Book

Download your copy today.

Research
Search for reports and white papers from industry vendors and analysts.

This Week at NewArchitect.com Subscribe now to our free email newsletter and get notified when the site is updated with new articles







Day of Defeat Online Gaming

 New Architect > Archives > 2001 > 09 > Programming with Perl  

Spanning and Sorting Your Data

By Randal L. Schwartz

I participate quite frequently in the Web-based community of Perl users known as the Monastery, located at perlmonks.org (www.perlmonks.org). Recently, a fellow "monk," as we call each other, wanted to know how to take a data table and generate pretty HTML from it. Simple tables aren't very difficult, but in this case many of the items in the table's vertical columns were identical. This monk wanted to span the identical data, to make the table easier to read.

The other monks proposed various solutions. One nice method used the HTML::Table module from the CPAN, which I had seen but not played with before. But, that solution spanned only the first column—though in the authors' defense, that's all that was being asked. However, I saw this as an opportunity to take the idea one step further.

I wanted to generate a spanned HTML table from a dataset where any column could span, not just the first. To try this out, I'd need some sort of data: something with many similar vertical data rows.

"Aha!" I said, "How about the output of Unix's ps utility?" After a dozen more minutes, I was using a CGI script to grab ps output and dump it into wonderful spanned columns. When I hit reload, the values would change. In fact, I was rather amazed to see how much it cleaned up the output to have those spanned items there. Take a look at Figure 1 to see what I mean.<>




  Day of Defeat Online Gaming

home | daily | current issue | archives | features | critical decisions | case studies | expert opinion | reviews | access | industry events | newsletter | research | careers | info centers | advertising | subscribe | subscriber service | editorial calendar | press | contacts


Copyright © 2006 CMP Media, LLC Read our privacy policy, your California privacy rights, terms of service.
SDMG Web sites: BYTE.com, C/C++ Users Journal, Developer Pipeline, Dr. Dobb's Journal, DotNetJunkies, MSDN Magazine, Sys Admin,
SD Expo, SD Magazine, SqlJunkies, The Perl Journal, Unixreview, Windows Developer Network, New Architect

web2