![]() |
|
laziness, impatience, and hubris | |
PerlMonks |
Re^5: Can you assign to pos() in a s/foo/bar/gby Jaikov (Initiate) |
on Feb 25, 2010 at 23:21 UTC ( #825406=note: print w/replies, xml ) | Need Help?? |
Thx John, your tip was very helpful, as it gives me the right idea...
Perhaps I did not explain good enough the scenario. But both your solutions have a little error, example: one-pass solution: s/(?<=class=")([^"]*)"\s*class="/$1 /g;But for smaller files with few iterations the while-loop solution is faster, probably because of the lookbehind operator. 1 while $s1 =~ s/class=\"([^\"]*)\"\s*class=\"([^\"]*)\"/class="$1 $2"/g;
Thx again,
In Section
Seekers of Perl Wisdom
|
|