>>>>> "RJK" == Ronald J Kimball <rjk@linguist.dartmouth.edu> writes: RJK> On Mon, Jun 21, 1999 at 02:02:57PM -0700, Randal L. Schwartz wrote: >> >>>>> "Chaim" == Chaim Frenkel <chaimf@pobox.com> writes: >> Chaim> I found this piece of code useful to generate an unpack format when I Chaim> needed to translate a columnar text file. >> Chaim> $fmt = ""; Chaim> while(<>) {chomp; $fmt |= $_}; >> Chaim> $fmt =~ y/ /X/c; Chaim> $fmt =~ s/(X+\s+)/"A".(length($1)-1)."x"/ge; >> >> It seems that "foo bar" would be incorrectly translated to "A3xA3" >> with this? I don't think you want to collapse \s+ there. >> RJK> It may seem that way, but what _actually_ happens (i.e. I ran the code) is RJK> that "foo bar" is translated to "A7xXXX". I guess that Chaim's code RJK> expects each field to be terminated by a space. The X+\s+ should actually be X+\s*, it failed to translate the last field. That also isn't the best solution, Randal worked around the problem by padding the input. But it may be easier to simply change the last entry to A* rather than padding. <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