l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
December 2: Social gathering
Next Installfest:
TBD
Latest News:
Nov. 18: Club officer elections
Page last updated:
2009 Aug 14 21:47

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] Perl - reading fixed width formats
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] Perl - reading fixed width formats



>>>>> On Thu, 13 Aug 2009 10:50:58 -0400, Peter Jay Salzman <p@dirac.org> said:

PJS> field 1: line 1, chars 1-4
PJS> field 2: line 1, chars 5-6
PJS> field 3: line 1, chars 7-11
PJS> field 4: line 1, chars 12 to EOL
PJS> field 5: line 2, chars 1-30
PJS> field 6: line 3, chars 1-10
PJS> field 7: line 4, chars 1-2

Are those all fixed number of columns?  IE, line 2 will always have
exactly 30 characters and will padded if the data is shorter than 30?

If so, then unpack() is probably your best bet for speed I'd think.  You
can read() in chunks of data based on the exact record length and then
use unpack to split apart the chunks.

Doing things like split/regexp/etc (as suggested) I think are
potentially easier to read and maintain and handle file format changes
much better though.  But in terms of manipulating data, treating the
data as binary will yield faster results I think.
-- 
\ Wes Hardaker                           http://pontifications.hardakers.net /
 \_____ "In the bathtub of history the truth is harder to hold than ________/
       \_______ the soap, and much more difficult to find." _______/
               \_________ -- Terry Pratchett ______________/
                         \__________________/
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Appahost Applications
For a significant contribution towards our projector, and a generous donation to allow us to continue meeting at the Davis Library.