in reply to Re^2: Refactoring challenge.
in thread Refactoring challenge.
Unfortunately, [the substitution] also removes any leading whitespace from the remainder of the string
Oops, I completely missed that. But adding a trailing
to $_consume() is enough to fix that.$_[0] =~ s/^\s+//;
Unfortunately, I cannot flatten the nesting in quite the way you have as the $pos ($length as you have it) will also be undefined if $first is undefined.
Both your original code and dragonchild's refactor contradict this - both use the returned $pos1 ($pos) unaltered when $first is undefined.
For now, the magic problem doesn't arise as $str is just a string (generated wholey within the outer layers of my code and will not have any magic attached)
As I remember it, the principle (and most embarrassing) time that it becomes a problem is when the parameter is tainted.
Hugo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Refactoring challenge.
by BrowserUk (Patriarch) on Mar 06, 2005 at 14:08 UTC |