in reply to Re: Convert a Tab-Delimeted File to XML
in thread Convert a Tab-Delimeted File to XML

I hate to point out something in Randalls code, but shouldn't the first split be on tabs and not on one or more spaces ? a label "First Name" could exist.
  • Comment on Re: Re: Convert a Tab-Delimeted File to XML

Replies are listed 'Best First'.
(jeffa) 3Re: Convert a Tab-Delimeted File to XML
by jeffa (Bishop) on Sep 30, 2001 at 06:45 UTC
    Good point - personally, i hate tab-delimited files. If my labels can contain whitespace, then i will use something like a colon or a semi-colon or maby even -=:TOMMY_LEE:=-

    i think merlyn chose \s+ to take care of situations where tabs and spaces could be inter-mixed.

    it all boils down to TIMTOWTDI ;)

    jeffa

      My comment would have broken merlyns code and I feel I should post an apology. A split on \t would have left @values with an extra linefeed, so to be able to handle a proper tab-separated header you also need to:
      chomp $labels[-1]
      after splitting on \t. If the header is really one-or-more-whitespace-characters-separated, then the original code is fine. Feel free to mod me down or take experience points or whatever is the punishment du jour :-)
      Naw man... *NIKKI SIXX* is a much better delimiter.

      /\/\averick