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

[FWP] Interpreting a columnar text file.



I found this piece of code useful to generate an unpack format when I
needed to translate a columnar text file.

	$fmt = "";
	while(<>) {chomp; $fmt |= $_};

	$fmt =~ y/ /X/c;
	$fmt =~ s/(X+\s+)/"A".(length($1)-1)."x"/ge;

<chaim>
-- 
Chaim Frenkel					     Nonlinear Knowledge, Inc.
chaimf@pobox.com				               +1-718-236-0183

==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org