Eric on 18 Jan 2006 16:09:45 -0000

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Perl question...

Quoting "Michael C. Toren" <>:

> On Wed, Jan 18, 2006 at 08:30:30AM -0500, Andrew Libby wrote:
> > Okay, so if you've got whitespace in your field values, something more
> > like this might work:
> It isn't entirely clear to me what the structure of the input file is
> based on the posts I've seen.  If the issue is that data can be found at
> predefined column numbers, but that sometimes tab characters are used to
> jump to the next tab stop, one solution is to simply to have the perl
> script expand tabs before parsing:
> 	use Text::Tabs
> 	while (my $line = expand <>)
> 	{
> 	    my $data = substr $line, 71, 35;
> 	    ...
> 	}
> -mct

I'll admit that one data record is not a good example!
The input file is manually maintained.  Therefore the person
sometimes used spaces and sometimes used tabs.  Randomly.  

I liked the regular expression solution on the presumption
that spaces embedded in the string fields would be singular while
the fields would be delimited by spaces and/or tabs.  
As it was, I manually edited the 1166 records by
searching for tabs and manually cleaning up the columns.
It took about 15 minutes and I could just "unpack" to my heart's
content.  Now 'expand' I've never heard of before!  Part of 
Text::Tabs I see.  Hummmm.....


Philadelphia Linux Users Group         --
Announcements -
General Discussion  --