http://qs321.pair.com?node_id=437067


in reply to Refactoring challenge.

This code is a mess, but works. Can you refactor it?

Sure. First, show me your unit tests, so that I can have confidence that my refactorings aren't breaking any unstated assumptions. In particular, on first read of the code, I'd want to see the tests that demonstrate (and document) what you expect

$str =~ s[^.{$pos1}\s*][];
to do and not do. Otherwise, I'd be left making educated guesses. That might work, or it might not.