News for hackers. Stuff that matters.
Re:Rob Pike: "Current Unix tools are weakened by the built-i... by Roboprog on Thursday June 14, 2012 @02:53PM (#4112907)
Seems like it shouldn't be too hard to write a little function (perl, python, whatever) to act as a "visitor" to hold this state, then just pass it little closures (maybe a hash/map?) to evaluate the regexs and pass the match into a code block?

Something like (perl):

&visit_matches(

{ ' +' => sub { $x += length( $1); },

  '#+' => sub { print $1, ' at ' $y, ',', $x'; $x += length( $1); },

  '\n' => sub { $y++; }
 
});

(not an exact match to the pseudo-awk, but enough to get the idea)

There are no comments on this comment yet.