Dvarin (dvarin) wrote,
Dvarin
dvarin

Was writing a perl script to compare some text data files. Since the separators are regular characters, the data strings might have escaped characters in them, so I'm faced with the problem of parsing out and unescaping the data components.

"Okay, so I'll go through the data one character at a time pulling them off into an accumulator, and when I see an escape character I'll take the next character literally, and when I see a separator I'll dump the accumulated string into the results array and reset it. Hmm, so first step--iterate through the characters. [flip][flip] Ummm... [flip][flipflip] Hm. There doesn't seem to be any function in perl to pull off the first character of a string, or any easy way to explode a string into an array... [flipflip] ... or even to pull out a character by its index, though I guess I could abuse substr for that. [flip]... [flipflip]... oh. Wait, I'm doing this totally wrong, aren't I."

[split][match][capture][match][substitution][concat][match][return!]

I've been programming in Java too long. See, in Java, they force you to hack your way through the jungle with a machete. In perl they give you a flamethrower, and afterward you root around in the ashes for the data you wanted. The styles are somewhat different.
Subscribe

  • Continuing to hate technological progress

    My usage split of communication methods, until recently: Phone Call: Message demanding an immediate response or an extended discussion SMS: Short…

  • Amorous Footwear

    Randomly saw the touring company's performance Kinky Boots due to inheriting a ticket from someone who was unable to go. Apparently it won a Tony in…

  • (no subject)

    The internet is really large nowadays. This posting of the obvious brought to you by my not having paid any attention to it for like seven years and…

  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 5 comments