WebProWorld Dev Forum

Large Search Index
I need help, all you gurus. I'll try to give you as clear a picture as I can, of what I have.
Click to read more...

SEO Concerns for Database Structure
We're reviewing a site for a company that is ranking poorly on the search engines (especially Google) for SEO services.
Click to read more...

Date function in Access
I have accidently used the name date in one of my table fields. When I tried to use the date funtion later down the track Access refered to the date used in one of my table field.
Click to read more...


Recent Articles

How Old is That File?
Sometimes you want to know the age of a file. Perl has a "-M" test that gives you age in days, but this customer needed it in minutes. That's easy:

ActiveState's Perl Dev Kit 6.0
ActiveState announced the release of Perl Dev Kit 6.0, the newest version of its industry-standard toolkit for easily creating, building and deploying applications with Perl.

Handling Missing Data in Inputs
Missing data can be very annoying to a programmer. In fact, it is so annoying that very often we'll write separate programs to clean up data and eliminate unpleasant conditions so that the main program doesn't have to deal with it.

PERL Extensibility Enhancements
OpenService announced the availability of NerveCenter 4.0, Open's network fault management and real-time correlation technology. This release adds the first major platform addition to the NerveCenter product line in years - support for Red Hat Enterprise Linux - as well as significant performance enhancements to NerveCenter's industry-standard PERL extensibility for all supported platforms.

New Updated Perl Book
Commonly used for CGI programming and extracting and translating data, Perl is the workhouse of the Internet.

More Perl Sorting
Perl has an easy to use "sort" function. For example, you might have an array like this: @month=("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

Writing COM Components in Perl Part 1
When you strip away all the layers of marketing hype and industry jargon, Microsoft's Component Object Model (COM) is simply a technology that allows you to create an object in the language of your choice, and to make the functionality of that object available to any other object...

12.02.04

Text::Autoformat: Smart Text Reformatting With Perl

By A.P. Lawrence

I've been using http://groups-beta.google.com/ for Newsgroup posting for a while now. It's convenient for me because of my nomadic life style where I have different ISP's and often different machines with varying OSes. Google only needs a browser, and they aren't overly fussy about that, either.

However, Google news posting does have some problems. Aside from the things that can't be helped except by complaining (like slightly broken Reference headers), the most annoying thing is that they don't let you set a posting width and they don't properly reformat quoted text.

Let's see why that's a problem. We'll take part of a short post by Jeff Liebermann:

I've considered tunneling into the hillside and building a cave, but
find the uphill neighbors septic tank a bit too close. However, I
don't think that living in a tree or cave will have an impact on
fixing the missing Reference line in the header.


Jeff has his line width set at 70, so if I reply to his post, the text isn't quoted too badly:

> I've considered tunneling into the hillside and building a cave, but
> find the uphill neighbors septic tank a bit too close. However, I
> don't think that living in a tree or cave will have an impact on
> fixing the missing Reference line in the header.


However, Google has now brought the width out two more characters, so if that is replied to again, we get:

> > I've considered tunneling into the hillside and building a cave, but
> > find the uphill neighbors septic tank a bit too close. However, I
> > don't think that living in a tree or cave will have an impact on
> > fixing the missing Reference line in the header.


Successful CRM: Turning Customer Loyalty into Profitability
>>read the white paper

We're now very close to breaking Google, and in fact one more reply would do it, causing the text to exceed their line width and wrap in an ugly way:

> > > I've considered tunneling into the hillside and building a
cave, but
> > find the uphill neighbors septic tank a bit too close.
However, I
> > don't think that living in a tree or cave will have an
impact on
> > fixing the missing Reference line in the header.


Some newsreaders automatically reflow quoted text so that the line width doesn't continue to build with each nested reply. Perhaps Google will do that someday, but in the meantime, I can use Text::Autoformat. This Perl module understands quoting levels, so it fixes things up nicely. Let's reformat this:

> > I've considered tunneling into the hillside and building a cave, but
> > find the uphill neighbors septic tank a bit too close. However, I
> > don't think that living in a tree or cave will have an impact on
> > fixing the missing Reference line in the header.


to a 70 character width:

> > I've considered tunneling into the hillside and building a cave,
> > but find the uphill neighbors septic tank a bit too close.
> > However, I don't think that living in a tree or cave will have an
> > impact on fixing the missing Reference line in the header.


Nicely done. The perl code is just:

#!/usr/bin/perl
use Text::Autoformat qw(autoformat);
while(<>) {
$old .= $_;
}
$newstuff = autoformat($old, {left=>0, right=>70, all=>1});
print $newstuff;


*Originally published at APLawrence.com


About the Author:
A.P. Lawrence provides SCO Unix and Linux consulting services http://www.pcunix.com

About PerlProNews
PerlProNews is a collection of news and commentary designed to keep you in step with the ever evolving landscape of Perl environments. News and Advice for Perl Professionals

PerlProNews is brought to you by:

SecurityConfig.com NetworkingFiles.com
NetworkNewz.com WebProASP.com
PerlProNews.com SQLProNews.com
SysAdminNews DevWebPro.com
LinuxProNews.com WirelessProNews.com
CProgrammingTrends.com ITCertificationNews.com

-- PerlProNews is an iEntry, Inc. publication --
iEntry, Inc. 880 Corporate Drive, Lexington, KY 40503
2004 iEntry, Inc.  All Rights Reserved  Privacy Policy  Legal

archives | advertising info | news headlines | free newsletters | comments/feedback | submit article

Database Forum News and Advice for Perl Professionals PerlProNews News Archives About Us Feedback PerlProNews.com About Article Archive News Downloads WebProWorld Forums iEntry Advertise Contact Jayde