Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of jjore (6662)

Monday August 31, 2009
02:07 PM

Whither Ruby's Text::Balanced?

[ #39560 ]

Today at work the toy problem of extracting some data from $more_json in a line like "$json|$more_json". The obvious thing seemed to use Text::Balanced to skip the first $json, snip off the '|' and then use a real JSON parser on the next json blob.

So uh... there's no Text::Balanced in Ruby. Not that I can find. We solved our work problem by just declaring that we'd only use delimiters which didn't occur in our input so we wouldn't need to find a Ruby Text::Balanced. I'm thinking maybe the easiest thing to do if we do turn out to need this in Ruby will be to write a gem that embeds a Perl interpreter. Then Ruby's Text::Balanced is just a short adapter over the Perl version.

It's just a thought though.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • rubycritic...or rubytidy

    And while I'm at it, where's perls Rake? imho, it kicks Makefile.PL in the ass sometimes.

    • What's Rake? Details man, details. What are we missing exactly?

      • It's make, except in Ruby. Module::Build isn't perl's Rake because M::B is focused on modules. Rake encompasses comparable gem tasks as M::B but is also a generally useful tool, just like make, except not evil.

      • Think “DSL around Algorithm::Dependency for typical file-munging tasks” – roughly. Using the Rake Build Language [] has a bunch of examples where you can see how it looks.

        TinyMake [] could be a rendition in Perl, but I find it a bit too underengineered to be truly useful…

        I had some notes somewhere and have made a few starts at building a Rake clone, but I haven’t felt I got quite far enough with the concepts to start building something.

  • Ruby has nitpick at []. FWIW, tt's oppressively slow and has the following checks:

    • An assigment is being used as a condition: ...
    • The method ... is empty
    • The branches of 'if (...)' are identical
    • A rescue is capturing Object or Exception, which may hide errors.
    • A rescue is returning ... directly and may not handle an error.
    • One or more variables are being shadowed (...)
    • A block is being yielded to without a check for block_given?
    • The argument ... is unused
    • The variable ..